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?

mathew
  • 1,179
  • 2
  • 13
  • 24
  • 1
    see : http://lists.mysql.com/mysql/218317 – Haim Evgi Jul 14 '10 at 10:52
  • 1
    In MySQL the terms *key* and *index* tend to be used interchangeably, as pointed out in the post given by haim evgi. In MS SQL, they can refer to different things: http://stackoverflow.com/questions/366186/is-the-sql-server-unique-key-also-an-index#answer-366200 – Mike Jul 14 '10 at 11:03

1 Answers1

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]

Naktibalda
  • 13,705
  • 5
  • 35
  • 51
  • 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 04 '13 at 10:05
  • 1
    Please be clearer about why KEY and INDEX can be used interchangeably. I found http://lists.mysql.com/mysql/218317 (from Haim Evgi's comment above) helpful. – William Gross Jun 23 '14 at 18:25