From: | "Oliver Elphick" <olly(at)lfix(dot)co(dot)uk> |
---|---|
To: | Mark Nelson <MCN(at)cc(dot)usu(dot)edu> |
Cc: | PGSQL-NOVICE(at)postgresql(dot)org |
Subject: | Re: find and replace content |
Date: | 2001-08-15 11:51:10 |
Message-ID: | 200108151151.f7FBpAYx023556@linda.lfix.co.uk |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
Mark Nelson wrote: PHP and Postgres last week. I have a bunch of
>pages that bring in different content depending on the page. Now
>I need to change a name that appears in the content throughout
>these pages. Is there a way to do a find and replace throughout
>the database searching the content? I want to do something like
>replace all occurences of Jones with Johnson.
>
>Can I do this directly or do I need to write a simple php page to
>do this? I know this sounds simple and the solution probably is
>too, but after hours of searching I still cannot find it.
It depends how you have stored the names.
If the name is in a field by itself, it's easy:
UPDATE table SET name = 'New Name' WHERE name = 'Old Name';
If the name is mixed up with other text, you may be able to do
a substitution using string functions. If not, you could COPY the
table out to a flat file, use sed to edit the flat file and then
COPY it back in. That could all be put into a script driven by
command line parameters.
--
Oliver Elphick Oliver(dot)Elphick(at)lfix(dot)co(dot)uk
Isle of Wight http://www.lfix.co.uk/oliver
PGP: 1024R/32B8FAA1: 97 EA 1D 47 72 3F 28 47 6B 7E 39 CC 56 E4 C1 47
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C
========================================
"Praying always with all prayer and supplication in the
Spirit, and watching thereunto with all perseverance
and supplication for all saints." Ephesians 6:18
From | Date | Subject | |
---|---|---|---|
Next Message | Mark Nelson | 2001-08-15 14:52:55 | replacing within cells |
Previous Message | Martijn van Oosterhout | 2001-08-15 09:16:13 | Re: Re: nextval, sequences and sequencenames |