NYCPHP Meetup

[nycphp-talk] Replacing a string within many tables, unknown columns

Chris Snyder chris at psydeshow.org
Fri Feb 14 11:03:46 EST 2003


Lynn, Michael wrote:

>I need to be able to replace every occurance of a string in many tables, many columns.  The string appears in tables in various places and usually embedded in a string type or var type column... The
>string will not be the entire contents of the column so a replace won't work.
>
>Eg: my development database contains url links to the development web site.  When I copy the tables to production, I want to search and replace every occurance of the development urls with production
>urls throughout the entire database.
>
>  
>
Many columns, many tables? Ouch.

It seems like the best way to do this, since you're migrating the data 
anyway, is to take the contents of the mysqldump you do to get the data 
out of your development database, and run a search-and-replace operation 
on it before feeding it into the production database.

See mysqldump in the "Backing up your database" section of the MySQL 
documentation-- the sql file you get is plain text, and the data therein 
is processable in a myriad of ways as long as you don't distrub the SQL 
itself.

    chris.

-- 
HIP HOP CLOWN MONTH
booth of the day: all day, every day
http://hiphopclown.org/berylium/showcase/





More information about the talk mailing list