tags:

views:

12

answers:

2

I have a table that has 7000 rows,
I added a new column to this table
The table has a mysql DateTime so.

When i updated the table to fill in this new table it updated the datetime,

I took an sql dump just before i did the update so now i need to use the sql dump to revert the datetime back (and only that column).

How do i do that?

A: 

Restore the dump to a second table. Select the ID and datetime from that table. Use those results to update the rows in the original table corresponding to the IDs you got.

Borealid
A: 

There are a couple ways I can think of to do this off the top of my head.

First is to create another mysql database and load the dump into that database (make sure it's not going to load into the first database from a use commmand in the dump), and then use the data from that database to construct the update queries for the first.

The second, easier, more hackish way, is to open the dump in a text editor, pull out just that table, and find and replace to make update statements for just that column based on primary key instead of inserts. You'd need to be able to find and replace on patterns.

A third way would be to load the dump in an abstract sql tool letting it do the parsing for you, and write new queries from the data in the abstract syntax trees.

A fourth, again hackish, possibility, if this isn't a live system, is to rollback and re-perform the more recent transformations (only if they are simple).

Cirdec