Can I import a single column from a SQL dump file since hunders of new rows have been added since.?

Go To StackoverFlow.com

0

I removed, what at the time I thought, was an unnecessary field/column from a table in mysql and now would like to import it back into the table. Just before I dropped the column, I did a backup of the whole table. Since then, close to 1000 new rows have been added.

How can I add the column and information back to the table?

I have a sandbox that I can "play" with. I have tried but have yet to get the proper end result. Thank you in advance.

Not sure if it matters but, the system is fedora 16.

2012-04-04 18:07
by DaedBaet


1

What I would do is to load your dump into another table (e.g. table_bak, you might need to do this in your sandbox and redump). Then add your column back in to your live table with a sensible default value. Then you should be able to bring the old data back like this

UPDATE `table`,`table_bak` SET `table`.restored_column=`table_bak`.restored_column WHERE `table`.pk_id=`table_bak`.pk_id
2012-04-04 18:11
by liquorvicar
Thank you, liquorvicar - DaedBaet 2012-04-04 23:18
Ads