Reputation: 66650
I have database table but without the index, and I want to add index id
to that table, that will be uniqe for each row, how can I do this using mysql?
Upvotes: 4
Views: 439
Reputation: 16223
Assuming you don't have a key on the table already you can do this:
ALTER TABLE whatever ADD id Int NOT NULL AUTO_INCREMENT PRIMARY KEY;
And remember you can add FIRST
to the end of that line to make it the first column which would be a good idea for an id.
Upvotes: 11