Re: find and replace content
От | Oliver Elphick |
---|---|
Тема | Re: find and replace content |
Дата | |
Msg-id | 200108151151.f7FBpAYx023556@linda.lfix.co.uk обсуждение исходный текст |
Ответ на | find and replace content (Mark Nelson <MCN@cc.usu.edu>) |
Список | 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.Elphick@lfix.co.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
В списке pgsql-novice по дате отправления: