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

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -