[thelist] MySQL: transfer data to table with different structure?

Fred Jones fredthejonester at gmail.com
Sun Mar 9 13:08:25 CDT 2008


Frank wrote:
> I'm upgrading a client from a (very) previous version of a CMS that 
> I've written to a newer version. I want to transfer their data over, 
> but the table structures are slightly different. The tables and 
> fields are essentially the same but have variation in naming schemes.
> 
> Example:
> old setup->    articles.ArticleTitle
> new setup->  pub_articles.article_title

Two options:

1. Write a script that fetches the data from the old DB and then INSERTs 
it into the new one.

2. Write a script that fetches the data from the old DB and then writes 
out (to a text file) the SQL statements to INSERT the data into the new 
DB. Then run that SQL.

#1 may tend to be a lot slower, in my experience. When doing a very 
large transfer of this sort, I found that it was impossible to use #1 
due to this and I found #2 to be an excellent alternative. My script 
wrote out a huge SQL file which I just imported into MySQL, gave it a 
few hours, and it worked beautifully.

Dat's my 2 cents!

Fred



More information about the thelist mailing list