30

I have seen couple of sample tables one is with UNIQUE INDEX and other is with UNIQUE KEY. what is the difference between two?? or both are same?

2

1 Answer 1

15

CREATE TABLE
KEY is normally a synonym for INDEX.

You can use them interchangeably as described in syntax page
[CONSTRAINT [symbol]] UNIQUE [INDEX|KEY]

2
  • 10
    No, the syntax page does not say that INDEX and KEY are interchangeable, but can be used as the next argument for the UNIQUE constraint.
    – abbas
    Commented Jul 4, 2013 at 10:05
  • 1
    Please be clearer about why KEY and INDEX can be used interchangeably. I found lists.mysql.com/mysql/218317 (from Haim Evgi's comment above) helpful. Commented Jun 23, 2014 at 18:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.