Home » SQL Server » Difference between Primary Key and Unique Key in SQL Server

Difference between Primary Key and Unique Key in SQL Server

In our previous article we have see the difference between Asp.Net Web Form and Asp.Net MVC, today we will see the difference between PK and UK.

Difference between Primary Key and Unique Key in SQL Server

Primary Key Unique Key
Primary Key creates a Clustered index Unique Key creates a Non Clustered Index
Primary Key does not allow null value Unique Key allows only 1 null value.
A table can have only 1 Primary Key A table can have more then 1 Primary Key
Primary Key is a unique key identifier of the record Unique-key is to prevent duplicate values in a column
Primary Key has to be unique. Unique Key does not have to be the primary key.
In Primary Key column you can’t delete or change the value In Unique Key column you can delete or changes it’s value

I love to here from you if I miss any other difference then listed above.

About

Site Admin is a writer of http://www.codingsharp.com website. He is a software professional with hands on 4+ years of experience. Generally he writes an article about Javascript, SQL Server and JQuery. Here he shares his notes, experiences, examples.

About Coding Sharp

Coding sharp is a blog where you can find the authors personal experience, tutorials, examples, code samples, resources related to C#, Asp.Net, Linq, Ajax, MVC, Entity Framework, SQL Server, jQuery, Visual Studio.

Pages