Getting a data dump of a table with a column name

I need a dump of specific table data from one database. I use the command mysqldump -t -uroot -p TEST Person Address Department> /home/Dumps/Desktop/dumb.sql My problem is that the database into which I am going to import this dump has the same tables but different number of columns. For example, the Person table in New DB contains another column compared to the Person Test Db table. Because of this, I was not able to import my landfill. It shows the error "The number of columns does not match the number of values ​​in row 1" I found what the problem is. In dump.sql, insert queries look like

INSERT INTO `Person` VALUES (1,'1',NULL,'2012-05-22 08:05:34',NULL,'shobana',NULL), (2,'2',NULL,'2012-07-16 09:56:33',NULL,'prabu',NULL); 

But if so:

 INSERT INTO `Person` (column1,column2,column3,column4,column5,column6,column7) VALUES (1,'1',NULL,'2012-05-22 08:05:34',NULL,'shobana',NULL), (2,'2',NULL,'2012-07-16 09:56:33',NULL,'prabu',NULL); 

I will not have a problem.

Is there any command to get a data dump with matching column names.

Can anyone help me out? Thanks at Advance ..

+6
source share
1 answer

using:

 mysqldump --complete-insert .... 

This will add the column names and you can import them.

+13
source

Source: https://habr.com/ru/post/927425/


All Articles