Reputation: 10682
In mysql, when creating a table, you can append:
unique(username)
but i dont know how to alter a table to add that containt.
I was trying:
alter table Company constraint unique (username)
Upvotes: 2
Views: 6470
Reputation: 10682
I mixed up the syntax.
alter table Company add constraint unique (username);
but this will fail if there are duplicates... So either drop and recreate if it is a sample db, or delete out duplicates.
Upvotes: 4