MySQL Forums
Forum List  »  Newbie

Adding primary key afterwards
Posted by: Oskar Eriksson
Date: June 11, 2009 10:30PM

Hi, I have a table with data that lacked an appropriate primary key. None of it's current columns have any unique data in them.

So what I want to do is to add a primary key with auto increment! How would I go by doing this? Since adding a column gives it a NULL value on all current rows that can't be set to be primary key. The table has too many rows for me to be bothered manually seting values 1,2,3 ..

I'm sure there must be some useful function you can use? Maybe setting a function as a default value?

Options: ReplyQuote

Written By
Adding primary key afterwards
June 11, 2009 10:30PM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.