Both primary key and unique enforce uniqueness of the column on which they are defined. But, there are some differences as well which are as below:
Primary Key | Unique Key |
Creates a clustered index on the column | Creates a nonclustered index |
Doesn’t allow NULL | Allows one NULL only,but the unique key is defined on a column which is not null , then this unique key can also be used as an alternate primary key functionality to identify unique rows in a table. |
Only one Primary key can be created for a table. Multiple columns can be consolidated to form a single primary key. |
Any number of unique constraints can be added to a table |