What is Primary Key?

A primary key is a column, or a set of columns, whose value uniquely identifies each row in a table.

Primary Key explained

No two rows can share a primary key, and it cannot be empty. That makes it the reliable handle for finding, updating and joining to a specific row, such as customers.id.

Knowing which column is the key tells you what a row represents. Many wrong totals come from joining on something that looks like a key but is not unique.

Example

In a customers table, the id column is the primary key: customer 1042 is exactly one row, even if two customers share the same name.

Frequently asked questions

What is Primary Key?
A primary key is a column, or a set of columns, whose value uniquely identifies each row in a table.
Can you give an example of Primary Key?
In a customers table, the id column is the primary key: customer 1042 is exactly one row, even if two customers share the same name.