mysqldump: replace drop table in output with delete?

by akonsu   Last Updated September 11, 2019 23:06 PM

I am using mysqldump to dump some records in a table:

mysqldump mydatabase mytable --where="field=value"

this emits script that includes drop table mytable statement.

Since I use the --where option, when I replay the script, I want to overwrite only these records that satisfy the condition field=value. I want the emitted script to delete just these records:

delete from `mytable` where field=value

is there a way to achieve this?

Answers 1

Specify to not use any creation SQL with --no-create-info

mysqldump mydatabase mytable --no-create-info --where="field=value"

If you want to overwrite the records on reload of the mysqldump, just add --replace

mysqldump mydatabase mytable --no-create-info --replace --where="field=value"

I suggested --replace because REPLACE is a mechanical DELETE and INSERT.

Give it a Try !!!

July 22, 2013 19:19 PM

Related Questions

Cannot read sql statement into mysqlbinlog

Updated February 27, 2017 00:06 AM