Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mysqldump: Can you change the name of the table you're inserting into?

Tags:

mysql

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?

like image 272
A Question Asker Avatar asked Nov 07 '11 21:11

A Question Asker


1 Answers

After creating a mysql dump file you could do the following:

sed -i 's/`old-table-name`/`new-table-name`/g' old-table-name.dump

The sed command will search and replace the old table name with the new table name from within the mysql dump file.

like image 89
singh1469 Avatar answered Sep 20 '22 02:09

singh1469