Adding Auto Increment to a column without rebuilding the table
Is there a way to add Auto Increment to an existing column without having mysql rebuild the entire t开发者_如何学Goable?
Edit - I am doing an ALTER
, but it takes ages and ages, because mysql rebuilds the entire table structure. What this question is about is whether there is a way to speedup this process - after all, the logical operation of adding "auto increment" shouldn't have to touch any table data, it's just how mysql is implemented.
ALTER TABLE [table] ADD [columname] INT UNSIGNED NOT NULL AUTO_INCREMENT
Alternatively you could set the start number of the AUTO_INCREMENT
ALTER TABLE [table] AUTO_INCREMENT = [start]
精彩评论