开发者

help with insert mysql

I have some data from an ol开发者_StackOverflow社区d 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.


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


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 (...);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜