Thursday, August 16, 2012

What is the difference between unique key and primary key?

Answer:

 
This is a typical SQL Server interview question and below is the comparison sheet.

Unique Key
Primary Key
Unique key can have nulls
Primary key cannot have nulls.
In a single table we can create multiple unique keys.
In a single table we can have only one primary key.
It creates a non-clustered index by default.
It created a clustered index by default.
Both unique keys and primary keys can be referenced by foreign key.


 

No comments:

Post a Comment