Primary Key Vs Unique Key in SQL server

Primary Key Vs. Unique Key in SQL server
 

Primary Key

Unique Key

Primary key doesn’t allow Null values

Unique Key allows Null value. But only one Null value.

By default it create cluster Index

By default it create non cluster index.

Each table has only one primary key

Each table may have more than one unique key.

The number of Unique constraints per table limited by no of non-cluster index per table.

i.e. 249 for SQL server 2005

999 for SQL Server 2008 and later.

Logically Primary Key is a combination of Unique and NOT NULL Constraints.

Primary key and unique key, both support auto increment value.

Primary key and unique key can be made foreign key into another table.

Ebook Download
View all
Learn
View all