database - Cloning a table MYSQL and adding a unique ID? -
the code have been using clone table follows:
create table new_table original_table; insert new_table select * original_table;
however, there problem in new table want unique, auto incrementing id column.
but run column count doesn't match value count @ row 1 error
.
i know can use default keyword
, or leave id out , auto increment unsure how query should structured?
after added pk auto increment column (assuming first column) try this:
insert new_table select null,[all column names original_table] original_table;
Comments
Post a Comment