mysqldump default Parameter Add-drop-table

Source: Internet
Author: User

Mysqldump default Parameters add-drop-table original January 28, 2014 11:35:18 9214 received a colleague on the phone, said UAT the environment of a table was deleted, to restore a bit. The original is the new project UAT, from the test library with mysqldump export table structure on UAT execution. Due to the addition of a few table structure, the relevant personnel will not be audited. By developing a colleague to execute the upgrade table structure of the script, just after the execution of the discovery of business problems. After viewing it, I found a table missing from the UAT library. A script that examines the changes to the table structure, and finds a command to delete the table in the script. The original test library has a table with the same name as the table in the Uat library. This table should not be upgraded, but the table structure is exported with a fuzzy query, to find the table to be exported. So the result is a table that is exported more than one. Mysqldump when you export a table structure, it is add-drop-table by default before the Create statement, resulting in droptable commands before each table script.   With the help of mysqldump, you can see the following information: [SQL] View plain copymysqldump--help|more--add-drop-table add a drop table before each create.  (Defaults to In; Use--skip-add-drop-table to disable.)                 That is, by default, Mysqldump's add-drop-table is turned on. Mysqldump the table structure exported by default is as follows: Mysqldump-uroot-p-d-b testdb >testdb.sql [SQL] V  Iew Plain copydrop TABLE IF EXISTS ' test '; CREATE TABLE ' test ' (' id ' int (one) notnull auto_increment, ' name ' varchar (5) DEFAULT NULL, PRIMARY KEY (' id ')) E  Ngine=innodb auto_increment=4 DEFAULT Charset=utf8; If the mysqldump export table structure adds the--skip-add-drop-table parameter, only the CREATE statement, no delete。 mysqldump-uroot-p-d--skip-add-drop-table-b Testdb>testdb.sql[sql] View plain copycreate table ' test ' (' ID ' in T (one) Notnull auto_increment, ' name ' varchar (5) DEFAULT NULL, PRIMARY KEY (' id ')) engine=innodb auto_increment=4 DE     FAULT Charset=utf8; Summary: 1. Do not neglect the "seemingly simple" problem, many production accidents are caused by the "seemingly simple" problem. 2. The process should not be easily changed. You do not follow the process, it will not give you mercy when things go wrong.

mysqldump default Parameter Add-drop-table

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.