mysqldump entire structure but only data from selected tables in a single command

前端 未结 5 627
感情败类
感情败类 2021-01-30 05:39

My database has 3 tables: table1, table2 and table3

I would like to do a mysqldump on this database with the following conditions:

  • Dump structure for all t
5条回答
  •  时光取名叫无心
    2021-01-30 06:06

    It's actually pretty simple, use --where clauses on the tables where you don't want data and give it an always false condition. For instance, load data on foo and gah and only schema on bar:

    mysqldump -u ... -p... myDatabase foo bar --where='1=2' gah > myfile.sql
    

    So YES you can do this on one line.

提交回复
热议问题