Copy mysql table with ENUM fields

I am trying to copy an entire table from one mysql database to another. It almost works with

INSERT INTO `new-db`.`table` SELECT * FROM `old-db`.`table`; 

However, ENUM fields are incorrectly passed - they are always empty.

But the launch

 INSERT INTO `new-db`.`table` (an_enum_field) SELECT an_enum_field FROM `old-db`.`table`; 

works correctly.

Can I do something to correctly copy ENUM fields with the first expression?

+4
source share
1 answer

The order of the columns between the two tables should be the same. Otherwise, magic using * cannot correctly display the values.

Naming all columns clearly helps (second example from the question).

0
source

All Articles