I am using mysqldump to transfer a table from one database to another.
mysqldump -h host -u user -p password -e --single-transaction --no-create- info --default-character-set=utf8 --complete-insert --result-file=thisisaresult db table
I was wondering, however, if there is a way to change the name of the table you insert into? For example, I’d like this to insert into table_staging, or something like that. Is this possible, or am I going to have to just use sed?
I don’t think is possible when dumping data because there may be FK references to the table you are changing.
If there are no FK references to the table you wish to change then it is possible to just hand edit the resulting dump file:
Becomes
My recommendation would be to dump the data, re-import it into your new database, then run the alters to rename your table.