Alter combination of 2 existing columns as a unique key
am 19.04.2007 20:07:21 von James
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 are not unique, but combination is.
TIA,
James
Re: Alter combination of 2 existing columns as a unique key
am 20.04.2007 01:48:31 von gordonb.4k7va
>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 are not 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.