268.

What is difference between primary key and unique key?

Differences between Primary Key and Unique Key:

Primary Key:

  1. A primary key cannot allow null values. (You cannot define a primary key on columns that allow nulls).
  2. Each table can have at most one primary key.
  3. On some RDBMS a primary key automatically generates a clustered table index by default.

Unique Key:

  1. A unique key can allow null values. (You can define a unique key on columns that allow nulls).
  2. Each table can have multiple unique keys.
  3. On some RDBMS A unique key automatically generates a non-clustered table index by default.