views:

120

answers:

2

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/columns as i import them? I'm aware I could edit the dump file in theory, but that seems like a hack, and so far none of my editors can handle opening the 1.3 gb file (Yes, I've read the question about that on here. No, none of the answers worked for me so far.).

Suggestions?

+2  A: 

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).

Pekka
+1  A: 

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.

Morgan Tocker