Unique Fields in MySQL database
Is there a way to change a field to unique using an ALTER TABLE? Right now the only way to make something unique making it the primary key.
Thanks in advance
Is there a way to change a field to unique using an ALTER TABLE? Right now the only way to make something unique making it the primary key.
Thanks in advance
Mark Hensler posted this at 06:48 — 11th April 2001.
He has: 4,048 posts
Joined: Aug 2000
I *think* this will do it:
ALTER table_name ADD UNIQUE field_name
You can read about the mySQL ALTER TABLE syntax here
PDavis posted this at 14:07 — 11th April 2001.
They have: 10 posts
Joined: Oct 1999
Yeah, it's just like assigning a primary key, must have missed it the first time though.
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.