tags:

views:

36

answers:

2

Hi--

I have some data from an old table, with a lot of columns that I need to insert into a new table, with not quite as many columns.

If you simply try to import the sql dump data from the old table directly into the new one, you get an error:

Unknown column 'fake' in 'field list'

Is there a way to make this ignore the errors (INSERT IGNORE doesn't work!), without rewriting the whole dump file? The other option I've considered is altering the new table to add back in the old columns, then do the import, then alter again to drop those columns after the import.

Thanks for any ideas.

A: 

I would have change columnname so it fit the dump file, import it and then rename the columnname.

Codler
A: 

You could always alter the dump file to match the current database structure. A simple search & replace might just do it.

INSERT INTO old_table(field1, field2) VALUES(...);
vs
INSERT INTO new_table(new_field1, new_field2) VALUES (...);
the_void