[ACCEPTED]-mysql combined unique keys-unique-constraint
Accepted answer
You can define an index on multiple columns, e.g.:
CREATE UNIQUE INDEX arbitrary_index_name ON table_name (title, store);
0
Yes. Instead of two separate unique constraints 6 you should create a single unique constraint 5 on both columns.
The CREATE INDEX
syntax is:
CREATE [UNIQUE|FULLTEXT|SPATIAL] INDEX index_name
[index_type]
ON tbl_name (index_col_name,...)
[algorithm_option | lock_option] ...
For your 4 example it would look something like this:
CREATE UNIQUE INDEX index_name ON tbl_name (title,store);
You 3 will also have to drop the two incorrect 2 unique indexes that you created.
See the 1 documentation for more details on how to create indexes.
ALTER TABLE table_name
ADD UNIQUE INDEX( title
, store
);
0
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.