[ACCEPTED]-mysql combined unique keys-unique-constraint

Accepted answer
Score: 37

You can define an index on multiple columns, e.g.:

CREATE UNIQUE INDEX arbitrary_index_name ON table_name (title, store);


Score: 7

Yes. Instead of two separate unique constraints 6 you should create a single unique constraint 5 on both columns.

The CREATE INDEX syntax is:

    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.

Score: 1

You need a multi-column unique key.


Score: 1

ALTER TABLE table_name ADD UNIQUE INDEX( title, store);


More Related questions