[Cialug] Merging MySQL databases

Dave Weis djweis at internetsolver.com
Wed Jan 21 14:31:03 CST 2009


As long as they are mostly similar you should be able to select out the 
data into an sql-like format and do some munging with a text editor to 
make it work. An example might be

SELECT 'INSERT INTO newtable VALUES ' || field1, field2, 'Y', field3 || 
'\;' FROM oldtable;

You could also just do the SELECT and in emacs or another editor capable 
of regexp replacements do something like

query-replace-regexp
^
INSERT whatever

query-replace-regexp
$
; control-q control-m

to put the insert stuff at the front and the semicolon on the end.

dave

On Wed, 21 Jan 2009, Nathan C. Smith wrote:

>
>
> I have two databases from a program I use and two different versions.
>
> I want to merge the data from the old database into the new database.  The Fields are almost the same but I'm not sure what tools I should use to do this.
>
> Are there better ways/tools than phpMyAdmin to dump the old data out of the old database, map the correct fields in the new database and import the data?
>
> Thanks for any pointers
>
> -Nate_______________________________________________
> Cialug mailing list
> Cialug at cialug.org
> http://cialug.org/mailman/listinfo/cialug
>

-- 
Dave Weis
djweis at internetsolver.com
http://www.internetsolver.com/



More information about the Cialug mailing list