268.
What is difference between primary key and unique key?
View Description
Differences between Primary Key and Unique Key:
Primary Key:
- A primary key cannot allow null values. (You cannot define a primary key on columns that allow nulls).
- Each table can have at most one primary key.
- On some RDBMS a primary key automatically generates a clustered table index by default.
Unique Key:
- A unique key can allow null values. (You can define a unique key on columns that allow nulls).
- Each table can have multiple unique keys.
- On some RDBMS A unique key automatically generates a non-clustered table index by default.