I am trying to alter a table which has no primary key nor auto_increment column. I know how to add an primary key column but I was wondering if it’s possible to insert data into the primary key column automatically (I already have 500 rows in DB and want to give them id but I don’t want to do it manually). Any thoughts? Thanks a lot.
Share
An
ALTER TABLEstatement adding thePRIMARY KEYcolumn works correctly in my testing:On a temporary table created for testing purposes, the above statement created the
AUTO_INCREMENTidcolumn and inserted auto-increment values for each existing row in the table, starting with 1.