MySQL commands: Difference between revisions

Jump to navigation Jump to search
92 bytes added ,  24 April 2018
Line 25: Line 25:


Replace / overwrite the current data  
Replace / overwrite the current data  
* Run {{kbd | key=<nowiki>mysqldump</nowiki>}} with the option {{kbd | key=<nowiki>--replace</nowiki>}}<ref>[https://dev.mysql.com/doc/refman/8.0/en/mysqldump.html#option_mysqldump_replace MySQL :: MySQL 8.0 Reference Manual :: 4.5.4 mysqldump — A Database Backup Program]</ref> "Write REPLACE statements rather than INSERT statements."
* Run {{kbd | key=<nowiki>mysqldump</nowiki>}} with the option {{kbd | key=<nowiki>--replace --no-create-info</nowiki>}}<ref>[https://dev.mysql.com/doc/refman/8.0/en/mysqldump.html#option_mysqldump_replace --replace]</ref><ref>[https://dev.mysql.com/doc/refman/8.0/en/mysqldump.html#option_mysqldump_no-create-info --no-create-info]</ref>: (1) {{kbd | key=<nowiki>--replace</nowiki>}}: "Write REPLACE statements rather than INSERT statements." (2) {{kbd | key=<nowiki>--no-create-info</nowiki>}}: "Do not write CREATE TABLE statements that create each dumped table." & "Do not add a DROP TABLE statement before each CREATE TABLE statement"
* Manually remove the {{kbd | key=<nowiki>drop table</nowiki>}} & {{kbd | key=<nowiki>create table</nowiki>}} syntax in the sql file.


Append the current data
Append the current data
* Run {{kbd | key=<nowiki>mysqldump</nowiki>}} with the option {{kbd | key=<nowiki>--insert-ignore</nowiki>}}<ref>[https://dev.mysql.com/doc/refman/8.0/en/mysqldump.html#option_mysqldump_insert-ignore MySQL :: MySQL 8.0 Reference Manual :: 4.5.4 mysqldump — A Database Backup Program]</ref> "Write INSERT IGNORE statements rather than INSERT statements."
* Run {{kbd | key=<nowiki>mysqldump</nowiki>}} with the option {{kbd | key=<nowiki>--insert-ignore --no-create-info</nowiki>}}<ref>[https://dev.mysql.com/doc/refman/8.0/en/mysqldump.html#option_mysqldump_insert-ignore --insert-ignore]</ref>: (1) {{kbd | key=<nowiki>mysqldump</nowiki>}} with the option {{kbd | key=<nowiki>--insert-ignore</nowiki>}}:  "Write INSERT IGNORE statements rather than INSERT statements."
* Manually remove the {{kbd | key=<nowiki>drop table</nowiki>}} & {{kbd | key=<nowiki>create table</nowiki>}} syntax in the sql file.


==== Exporting entire data ====
==== Exporting entire data ====

Navigation menu