Alter combination of 2 existing columns as a unique key
2 Message(s) by 2 Author(s) originally posted in mysql database
| From: James |
Date: Thursday, April 19, 2007
|
To alter 1 column to a unique key,
ALTER TABLE user MODIFY COLUMN id INT NOT NULL
UNIQUE ;
But how to set
combination of 2 columns as a unique key?
Individual keys aren't unique, but combination is.
TIA,
James
| From: gordonb.4k7va |
Date: Thursday, April 19, 2007
|
To alter 1 column to a unique key,
ALTER TABLE user MODIFY COLUMN id INT NOT NULL UNIQUE;
But how to set combination of 2 columns as a unique key?
Individual keys aren't unique, but combination is.
ALTER TABLE user ADD UNIQUE (id,domain);
That just adds an index. You might need to drop an old one first. Or not.
Next Message: CONTRACT EMPLYER SEEKS EXPERIENCED PHP/MY SQL/DATABASE/ INTERGRATION/(HAVING WEB SERVER EXPERIENCE WINDOWS 2003 HELPFUL