0

I've googled about the differences between pk and uk. I've read QA on stackoverflow regarding the pk and uk.

Can please anyone in simple terms briefly tell me in what situation would i be preferring pk over uk or vice -versa.

Regards, Ankit

Ankit
  • 609
  • 2
  • 10
  • 26
  • http://dba.stackexchange.com/q/20204/5203, http://dba.stackexchange.com/q/15572/5203 – GSerg Aug 11 '14 at 10:48
  • also, http://stackoverflow.com/questions/9565996/difference-between-primary-key-and-unique-key – NoobEditor Aug 11 '14 at 10:49
  • The implementation of primary keys varies by database, so the relative merits of unique indexes versus primary keys depends on the database engine. – Gordon Linoff Aug 11 '14 at 10:57

1 Answers1

1

If your column has all the distinct values and all not null values, use primary key and if it can insert only one null value along with all other distinct values, consider using unique key.

whywake
  • 880
  • 10
  • 29