Tuesday 15 Oct 2013

Tuesday 15 Oct 2013

35 down vote accepted

An ALTER TABLE statement adding the PK column seems to work in my testing:

ALTER TABLE tbl ADD id INT PRIMARY KEY AUTO_INCREMENT;

On a temporary table of my own, the above statement created the AUTO_INCREMENT id column and inserted auto-increment values for each existing row, starting with 1.

Comments