Documentation Home
MySQL 5.7 Reference Manual
Related Documentation Download this Manual Excerpts from this Manual

MySQL 5.7 Reference Manual  /  ...  /  Dumping Table Definitions and Content Separately Dumping Table Definitions and Content Separately

The --no-data option tells mysqldump not to dump table data, resulting in the dump file containing only statements to create the tables. Conversely, the --no-create-info option tells mysqldump to suppress CREATE statements from the output, so that the dump file contains only table data.

For example, to dump table definitions and data separately for the test database, use these commands:

shell> mysqldump --no-data test > dump-defs.sql
shell> mysqldump --no-create-info test > dump-data.sql

For a definition-only dump, add the --routines and --events options to also include stored routine and event definitions:

shell> mysqldump --no-data --routines --events test > dump-defs.sql

Download this Manual
User Comments
  Posted by Todd Keup on February 23, 2011
It would be nice to be able to have only the DROP TABLE statements. I created a workaround using mysqldump and perl:

mysqldump -u username -p database --skip-opt --add-drop-table --skip-comments --no-data | perl -pe "s/^([^D]|drop\S)[^\n]*\n//ig" > test.sql
Sign Up Login You must be logged in to post a comment.