Skip to main content

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

  1. Uniqueness: the primary key's value never repeats in any other record of the table.
  2. Mandatory: a field that's a primary key can never be empty (NULL).
  3. Identifying records: it's how the database knows exactly which record is which.
  4. Example: in an Employees table, the ID field could be the primary key, where 1 is the first employee, 2 the 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 ready
Premium

A concise answer to help you respond confidently on this topic during an interview.