Can we make existing column as primary key?
Can we make existing column as primary key? I Have one column name Token and I'm generating random numbers and saving it as token but sometimes it saves duplicate tokens so I want to make it unique. I just want to know will it affect existing records Did you use php to interact with sql? – Vito Ferrulli Jun 29 at 9:19 @VitoFerrulli Yes – Jordan Jun 29 at 9:41 3 Answers 3 If you try to add a unique constraint (or primary key constraint) to a column that contains non-unique values, the alter statement will just fail. You need to first update the column so all values are unique (or remove duplicates), and ...
