What are the differences between primary key and unique key

In database world the term primary key and unique keys are very much known to all. Both the keys are used to uniquely identify rows in a table. They have similarities and at the same time they have some differences:
Following are some of the differences:
Primary keyUnique key
Primary key can't be nullUnique key can be null
Primary key can be just one in a tableUnique key can be multiple in a table
Primary key slightly faster than Unique keyUnique key slightly slower than primary key
Primary key can span multiple fields in a tableUnique key can also be span to multiple fields in a table

Comments