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
    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. Jun 23, 2014 at 18:25

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

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

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