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 −

Usage

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.

Volume

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.

Duplication

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.

Modification

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

Updated on: 15-Jun-2020

665 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements