Unique Key in RDBMS

Many users consider Primary Key as Unique Key, since both uniquely identify a table, but Unique Key is different from Primary Key. Unique Key accepts null values and Primary Key cannot have null.

Let us compare Primary Key and Unique Key and understand its concept −


A Unique Key is used to prevent duplicate values in a column. Primary Key provided uniqueness to a table.

NULL Values

A primary key cannot accept NULL values; this makes Primary Key different from Unique Key, since Unique Key allows one value as NULL value.


A table can only have a single Primary Key, whereas a Unique Key can be more than one if you need it in the table.


Unique Key ensures that data is not duplicated in two rows in the database. A row in the database can have null in case of Unique Key.


You cannot modify a Primary Key, but a Unique Key can be modified.