Unique keys accept null values whereas primary keys not.
When any field declared as a unique key ,it can be null and can contain same value more than one time, but if that field declared as a primary key that will not be null and can not contain duplicate data. Following points are more brings out more differences between Prinmary key and Unique key:
- Unique keys accept null values where as Primary keys not
- Unique keys contains duplicate data where as primary keys are not
- Unique keys generates Non-clustered index where as Primary keys contains clustered-index
- A table contains more than one unique key whereas a table contain only one primary key.
Similarity between Primary key and Unique Key in Table:
- A foreign key can be referenced by a primary key and Unique key also.