Serhii Danovskyi
Serhii Danovskyi

Reputation: 394

mysql dump - exclude some table data and no-data

I have a big database with 100 tables I'm need to create dump. 98 tables with data and 2 tables only structure

like this

mysqldump -u root -p {--no-data db.table99,  table10 } dbname > dump.sql

how can i do it with one request ?

Upvotes: 9

Views: 6500

Answers (1)

Jacques Amar
Jacques Amar

Reputation: 1833

mysqldump either includes the data, or doesn't. You can't do it with one query.

However, you can safely combine two mylsqdumps request into ONE file on bash. First one excludes the tables you don't want but has data, second one has only the 2 tables with no data:

{ command1 & command2; } > new_file

command1 => mysqldump -u root -p --ignore-table=dbname.table99 --ignore-table=dbname.table100 dbname

command2 => mysqldump --no-data -u root -p dbname table99 table100

Unfortunately, you'd have to supply the password twice. But since you want one line, you can put this in a bash script

Upvotes: 14

Related Questions