

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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.
- Related Questions & Answers
- Composite Key in RDBMS
- Secondary Key in RDBMS
- Super Key in RDBMS
- Surrogate Key in RDBMS
- Candidate Key in RDBMS
- Alternate Key in RDBMS
- Foreign Key in RDBMS
- Primary key Vs Unique key
- Difference between Primary Key and Unique key
- Count by unique key in JavaScript
- Remove unique key from MySQL table?
- RDBMS terminologies
- How add unique key to existing table (with non-unique rows)?
- Python - Unique values count of each Key
- Future of RDBMS