Lothar Lothar - 4 months ago 11
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
ALTER IGNORE TABLE mytbl ADD UNIQUE (columnName);