Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Append dump to existing MySQL dump file

i need to Dump all data for 2 tables and a subset of data from another 2 tables in a MySQL database. So suppose i have tables t1,t2,t3,t4, I need full dump of t1 and t2 and get it using

mysqldump -u... -p... mydb t1 t2  > mydb_tables.sql

Now, i need to append this .sql file with dump for tables t3 ,t4 , but both are just subset of actual tables(like SELECT * from t3 where id<1000). Is it possible to append existing dump file mydb_tables.sql

Else, is there any method using which i can dump all 4 table data into a single file?

like image 568
mhn Avatar asked Dec 19 '14 11:12

mhn


1 Answers

You can use append method, like we append the regular files

eg:
    cat file2 >> file1

You can dump using ">>" instead of ">"

">" overwrites the destination file where as ">>" appends to destination file.

mysqldump -u... -p... mydb t1 t2  > mydb_tables.sql

mysqldump -u... -p... mydb t3 t4  >> mydb_tables.sql
like image 152
user2486495 Avatar answered Sep 22 '22 02:09

user2486495