![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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.