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

前端 未结 2 1154
执念已碎
执念已碎 2021-01-06 23:10

I\'m importing a legacy db to a new version of our program, and I\'m wondering if there\'s a way to not import some columns/tables from the dump, and rename other tables/col

2条回答
  •  南笙
    南笙 (楼主)
    2021-01-06 23:46

    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.

提交回复
热议问题