Databases & SQL · reviewed in July 2026
Primary key
A primary key is a column, or combination of columns, that uniquely identifies each row in a database table. It cannot repeat or be empty (NULL), and it's usually generated automatically as an integer or a UUID.
Frequently asked questions
Can a table have more than one primary key?
A table has only one primary key, but that key can be made up of several columns at once (a composite primary key).
What's the difference between a primary key and a unique key?
Both guarantee values don't repeat, but a table can only have one primary key (which never allows NULL), while it can have several unique keys (which can allow one NULL).
What is the primary key used for besides identifying rows?
It's the reference point other tables' foreign keys use to relate to this one, and the database typically indexes it automatically for fast lookups.