patternsqlMinor
mysqldump: replace drop table in output with delete?
Viewed 0 times
deletewithmysqldumpreplaceoutputdroptable
Problem
I am using
this emits script that includes
Since I use the
is there a way to achieve this?
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=valueis there a way to achieve this?
Solution
Specify to not use any creation SQL with --no-create-info
If you want to overwrite the records on reload of the mysqldump, just add --replace
I suggested --replace because REPLACE is a mechanical DELETE and INSERT.
Give it a Try !!!
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 !!!
Code Snippets
mysqldump mydatabase mytable --no-create-info --where="field=value"mysqldump mydatabase mytable --no-create-info --replace --where="field=value"Context
StackExchange Database Administrators Q#46807, answer score: 4
Revisions (0)
No revisions yet.