Difference Between Primary Key and Unique key

Primary Key

Primary key is the unique identifier key of each record in a table.Primary key values must be unique.

  • Can have only one Primary Key in a table
  • In Sql not allow NULL values
  • It is Unique Identifier of an record


Unique Key

Unique Key is ensures all values in a particular column is different/unique.

  • Can have multiple Unique Key in a table
  • Value can be NULL
  • It cannot act as as unique identifier since multiple records may have NULL value.


Comments