HomeSQL ServerDifference between Primary Key and Unique Key

Difference between Primary Key and Unique Key

By default, primary key creates clustered index on the column and then enforces the uniqueness of the column whereas the unique key, by default creates a non-clustered index.

Primary Key

  • By default, creates Clustered index
  • Doesn’t allow null
  • Table can have only one Primary Key ( Can include multiple columns together )

Unique Key

  • By default, creates non clustered index
  • Accepts null value
  • Table can have many unique keys

Leave a Reply

You May Also Like

When dealing with a relational database management system (RDBMS) like SQL Server, compatibility level is an important concept to understand....
In this blog post, let’s learn about the error message “49975 – Unable to load controller client certificate due to...
In this blog post, let’s learn about the error message “49973 – Cannot remove tempdb remote file to local tempdb...