Lothar Lothar - 1 year ago 73
SQL Question

MySQL - Make an existing Field Unique

I have an already existing table with a field that should be unique but is not. I only know this because an entry was made into the table that had the same value as another, already existing, entry and this caused problems.

How do I make this field only accept unique values?

Answer Source
ALTER IGNORE TABLE mytbl ADD UNIQUE (columnName);