How to use ALTER TABLE to add a new column and make it unique?
How do I use ALTER TABLE to add a new column and make it unique? Depends on the DBMS, but I think the following is quite portable: ALTER TABLE table_name ADD column_name datatype ALTER TABLE table_name ADD UNIQUE (column_name) If you want to give a name to the UNIQUE constraint, you could replace the last command with this: ALTER TABLE table_name ADD CONSTRAINT constraint_name UNIQUE (column_name) if table is empty ALTER TABLE ADD (FieldName Type) ALTER TABLE ADD CONSTRAINT UNIQUE(FieldName) If you have data in table you need to this in three steps: Add column Fill values Add unique constraint