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

Popular posts from this blog

php - cannot display multiple markers in google maps v3 from traceroute result -

php - Boolean search on database with 5 million rows, very slow -

css - Text drops down with smaller window -