Difference between Primary key and Unique key?

Forums SQLDifference between Primary key and Unique key?
Staff asked 2 years ago

Answers (2)

Add Answer
Staff answered 2 years ago

Primary key will not accept NULL values whereas Unique key can accept NULL value once.

A table can have only one primary key whereas there can be multiple unique key on a table.

Staff answered 2 years ago

The primary key and unique key both provide uniqueness to the column.

The main difference between them is the primary key can identify each record in the table and can not accept NULL value, and the unique key prevents duplicate entries in a column except for a NULL value, but only one NULL is allowed per column.

A table cannot have more than one primary key column but a table can have more than one unique key column.

Subscribe

Select Categories