Reputation: 160
I have a database table that saved users profile information. Sometimes when users register, they get duplicated with an extra column with same records, sometimes not.
So, I wonder if I put Unique on the column Email to make sure the user don't dup when register.
I think it should be something like this:
ALTER TABLE users ADD UNIQUE idx_row_unique(email);
But in case the Unique give error, how do I undo it?
Just scare that after I change it, I don't know how to undo it.
Upvotes: 0
Views: 592
Reputation: 1189
I'd export the table structure and data first. That way if you need to put it back, you have the SQL right there.
Upvotes: 0
Reputation: 1253
If there are duplicate emails, the alter table should fail. So you're safe with that!
Upvotes: 2