1

I've seen some examples of SQL that read like this:

email varchar(64) COLLATE utf8_unicode_ci NOT NULL UNIQUE KEY

However it seems like it would be more efficient to write it like this:

email varchar(64) COLLATE utf8_unicode_ci PRIMARY KEY

Is this a fair judgement, or are they actually different?

J.Zil
  • 2,397
  • 7
  • 44
  • 78
  • 1
    Have a look into this SO post: http://stackoverflow.com/questions/707874/differences-between-index-primary-unique-fulltext-in-mysql – Bjoern Sep 06 '14 at 19:15
  • 3
    You can have more than one UNIQUE key in a table, while you're restricted to a single PRIMARY key. Not all databases can add foreign keys to UNIQUE constrained fields. – Joachim Isaksson Sep 06 '14 at 19:15
  • 1
    an email address shouldn't be used as a primary key... it can definitely be required to be unique, though. – gloomy.penguin Sep 06 '14 at 19:27

0 Answers0