In SQL, a Primary Key uniquely identifies each record in a table, cannot be null, does not allow duplicate values, supports auto increment, and only one Primary Key can exist per table; whereas a Unique Key ensures values are unique but can be null, does not support auto increment, and multiple Unique Keys can exist in a single table. For example, in an employee database, the EMP ID serves as the Primary Key because it must be unique and non-null, while fields like email or PAN card can be Unique Keys since they may be null but must remain unique.
Deep Dive
Prerequisite Knowledge
- No data available.
Where to go next
- No data available.
Deep Dive
Primary Key vs Unique Key in SQL Explained in 60 Seconds! #TechWithGitanjaliAdded:
First question, difference in primary key versus unique key. I give me the like real time example. Yeah, like we are using primary key, where we are using unique key. Yes, go ahead, please.
So, primary key is not null and it uh does not allow duplicate values. And unique key can allow null and it can and the values should not be duplicate.
Primary key is something that uh uniquely identifies the data record, but unique key is is something that does not really identify the unique record. It is just unique in the record and it can be null.
Correct.
>> Next is primary key supports auto increment, but unique key does not supports auto increment. There can be only one primary key in a table, but there can be multiple unique keys in a table. And uh real time use case of primary key and unique key is that if you have a database of employee database of any company, on first day when you join, EMP ID is the thing that is mandatorily generated and it cannot be left null or empty. So, other field other unique fields like contact, email or PAN card, Aadhaar card, they can be null, but it does not uniquely identify the record. EMP ID is something that is unique to each candidate. So, it cannot be left null. Correct. Great.
>> [music]
Related Videos
Agentforce NOW AMA: Build with React and Salesforce Multi-Framework
SalesforceDevs
490 viewsβ’2026-05-28
How agent o11y differs from traditional o11y β Phil Hetzel, Braintrust
aiDotEngineer
450 viewsβ’2026-05-28
WEB TECHNOLOGIES UNIT-2 | Degree 4th sem BCOM Computers web technologies unit-2 full explanationπ―β
LearnwithSahera
1K viewsβ’2026-05-29
More tests are always better? How to use AI to identify tests that bring little value
Alliance4Qualification
335 viewsβ’2026-05-29
Search Algorithms Explained in 60 Seconds! π€π¨
samarthtuliofficial
218 viewsβ’2026-06-01
People of Game of Thrones using JavaScript DOM
AltCampus
296 viewsβ’2026-05-30
Introduction to Problem Solving Part - 1 | Lecture 1 | Intermediate DSA
ascensionix
107 viewsβ’2026-05-29
So What's Odin Lang Even Good For
TechOverTea
131 viewsβ’2026-06-01











