Home > DeveloperSection > Forums > Difference between Primary Key and Unique Key
Ankit Singh

Total Post:341

Posted on    December-15-2015 10:02 PM

 Database SQL Server  SQL  SQL Server 2008  SQL Server 2012 

 1 Reply(s)
 675  View(s)
Rate this:
I want to use Difference between Primary Key and Unique Key please help me

aditya kumar Patel

Total Post:254

Posted on    December-15-2015 10:06 PM

 SQL Server, we have two keys which distinctively or uniquely identify a record in the database. Both the keys seems identical, but actually both are different in features and behaviours. In this article, I would like to share the key difference between primary key and unique key. For more help about keys in SQL Server refer the article Different Types of SQL Keys.

Difference between Primary Key & Unique Key
Primary Key
Unique Key
Primary Key can't accept null values.
Unique key can accept only one null value.
By default, Primary key is clustered index and data in the database table is physically organized in the sequence of clustered index.
By default, Unique key is a unique non-clustered index.
We can have only one Primary key in a table.
We can have more than one unique key in a table.
Primary key can be made foreign key into another table.

Unique Constraint can not be related with another table's as a Foreign Key.




Emp_Name varchar (50) NOT NULL,

Emp_Sal int UNIQUE,

Location int NULL



Modified On Dec-15-2015 10:06:27 PM

Don't want to miss updates? Please click the below button!

Follow MindStick