Wednesday, 28 October 2015

Difference between Primary Key and Unique key in SQL?

Primary key
Unique key
Primary key cannot have NULL value.
Unique key may have a NULL value.
Each table can have only one primary key.
Each table can have more than one unique key.
By default primary key is clustered index.
By default unique key is Non- clustered index.
Primary key can be related with another table’s as a Foreign Key.
Unique key cannot be related with another table’s as a Foreign Key.
We can generate ID automatically with the help of auto increment field.
Unique key is not support auto increment field.

No comments:

Post a Comment