What options do I have for importing a MySQL table using the InnoDB engine, where the table already exists, without losing read access to the existing table? Generally I am referring to situations where ALTER TABLE is really slow, and I instead want to dump the table, modify the dump, then import it.
If I use mysqldump to make the dump, then when I reinsert it drops the table before inserting, so read access is of course lost until the import is complete.
Can I simply change the tablename in the dump, import that, then when that’s done, drop the old table and rename the new one? Is there a better way? Thanks in advance.
If your table is of the same structure, I don’t see any problems. You need just to skip “DROP TABLE” operator. Almost all dumpers have the option to not include DROP TABLE/CREATE TABLE in the dumps. Personally I’d recommend Sypex Dumper.
If you want to change table structure without locking table, I think the best way is to use
pt-online-schema-change – ALTER tables without locking them