How to import a mysql dump while renaming some tables/columns and not importing others at all?

﹥>﹥吖頭↗ 提交于 2019-11-30 23:36:24

It's possible to not import some tables by denying permissions to do so, and using --force as a command line option.

Not importing some columns, or renaming them is not possible (at least without editing the dump file, or making modifications once imported).

My recommendation would be:

  • Import the tables into another database (1.3G should still be very quick).
  • Do your dropping/renaming.
  • Export the data to create yourself a new dump file.

If you're worried the dump contains multiple databases, the mysql command line tool has a -o flag to only import the one.

I'd say import it into a temporary database and do the changes live - possibly applying a pre-built script that does the necessary operations:

DROP TABLE ....
DROP TABLE ....
DROP TABLE ....
ALTER TABLE ..... DROP column ....

Then copy the finished result into the production database.

This can be very nicely automated as well.

It's likely to work out faster and with less problems than finding a tool that edits dumps (or, as so often with these things, trying out five different tools and finding out none works well).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!