Mysql – thesqldmup with data only

insertMySQLmysqldump

Is there a way to backup data using mysqldump –no-create-info … where the inserts in the backup file will look like this:

insert into t1(col1, col2)values(val1,val2);

instead of

insert into t1 values(val1,val2);

The problem with the second way is that when the table structure changes, the insert will not work. With the first way, the table structure, e.g, one more column is added, will not affect the insert statement.

I have to use the mysqldump. Any suggestions please?

Best Answer

Use --complete-insert

Use complete INSERT statements that include column names.

Source: http://dev.mysql.com/doc/refman/5.5/en/mysqldump.html#option_mysqldump_complete-insert