What is the difference between a primary key and a unique key?


PRIMARY KEY:-

  • It doesn’t allow Null values.
  • By default it adds a clustered index.
  • A table can have only one PRIMARY KEY.

UNIQUE KEY:-

  • Allows Null value. But only one Null value.
  • By default it adds a UNIQUE non-clustered index.
  • A table can have more than one UNIQUE Key Column[s].