What is a primary key (PRIMARY KEY)?
A primary key (PRIMARY KEY) is a field or combination of fields in a table that uniquely identifies every record.
The main points
- Uniqueness: the primary key's value never repeats in any other record of the table.
- Mandatory: a field that's a primary key can never be empty (
NULL). - Identifying records: it's how the database knows exactly which record is which.
- Example: in an
Employeestable, theIDfield could be the primary key, where1is the first employee,2the second, and so on.
Put simply, a primary key is a "passport" for every record in a table, making it unique and allowing tables to be linked together.
Short Answer
Interview readyPremium
A concise answer to help you respond confidently on this topic during an interview.