difference between primary key and unique key

Primary Key:

  • There can only be one primary key constraint in a table
  • In some DBMS it cannot be NULL – e.g. MySQL adds NOT NULL
  • Primary Key is a unique key identifier of the record

Unique Key:

  • Can be more than one unique key in one table
  • Unique key can have NULL values
  • It can be a candidate key
  • Unique key can be NULL ; multiple rows can have NULL values and therefore may not be considered “unique”

Leave a Comment