Saturday, August 11, 2012

Difference Between Primary key and Unique key


Primary key and Unique key constraints are important feature in database system. They have some key identity which is important to know.

Unique Key constraints:
Unique key constraint will provide you a constraint like the column values should retain uniqueness.
It will allow null value in the column.
It will create non-clustered index by default
Any number of unique constraints can be added to a table.

Primary Key Constraint:
Primary key will create column data uniqueness in the table.
Primary key will create clustered index by default
Only one Primary key can be created for a table
Multiple columns can be consolidated to form a single primary key
It won't allow null values.

No comments:

Post a Comment