Arnold Roa
Arnold Roa

Reputation: 7748

Mysql import from mysqldump in one single command?

I need to move a table each day from olddb to new db. I wonder if it is posisble to run this two commands in only one? without creating the .sql file

mysqldump -u user olddb table_name > moving.sql
mysql -u user newdb < moving.sql 

Upvotes: 0

Views: 610

Answers (1)

triclosan
triclosan

Reputation: 5724

mysql -u user -p -e 'insert into newdb.table_name select * from olddb.table_name' 

UPD

to use consition:

mysql -u user -p -e 'insert into newdb.table_name select * from olddb.table_name where olddb.table_name.mydate > ...' 

Upvotes: 1

Related Questions