Alex Rivera | Logout

Is it possible to make mysqldump skip the inserts for specific table?

Asked 2012-06-21T15:15:45.467
8

I'm regularly running mysqldump against a Drupal database and man, those cache tables can get huge. Considering that the first thing I do after reloading the data is clear the cache, I'd love it if I could just skip dumping all those rows altogether. I don't want to skip the table creation (with --ignore-tables), I just want to skip all those rows of cached data.

Is it possible to tell mysqldump to dump the CREATE TABLE statement skip the INSERT statements for a specific set of tables?

Edit
Report

1 Answer

10

There is a --no-data option that does this, but it affects all tables AFAIK. So, you'll have to run mysqldump twice.

# Dump all but your_special_tbl
mysqldump --ignore-table=db_name.your_special_tbl db_name > dump.sql

# Dump your_special_tbl without INSERT statements.
mysqldump --no-data db_name your_special_tbl >> dump.sql
answered 2012-06-21T15:20:10.890

Your Answer