tags:

views:

22

answers:

2

Is there a way to add Auto Increment to an existing column without having mysql rebuild the entire table?

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.

A: 

PHP - MySQL: Reorder/Reset auto increment primary key? - efreedom

http://efreedom.com/Question/1-740358/MySQL-Reorder-Reset-Auto-Increment-Primary-Key

ratty
A: 
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]
Harmen