Difference between primary key and unique key

  • Primary Key is used to identify a row (record) in a table, whereas Unique-key is to prevent duplicate values in a column (with the exception of a null entry).
  • By default SQL-engine creates Clustered Index on primary-key if not exists and Non-Clustered Index on Unique-key.
  • Primary key does not include Null values, whereas Unique-key can.
  • A table can have at most one primary key, but can have multiple Unique-key.
  • You can’t change or delete primary values, but Unique-key values can.

Leave a Comment

Your email address will not be published. Required fields are marked *