An ALTER TABLE
statement adding the PRIMARY KEY
column works correctly in my testing:
ALTER TABLE tbl ADD id INT PRIMARY KEY AUTO_INCREMENT;
On a temporary table created for testing purposes, the above statement created the AUTO_INCREMENT
id
column and inserted auto-increment values for each existing row in the table, starting with 1.