Skip to content
Justice Tech School

PRIMARY KEY

A primary key uniquely identifies each row. It cannot be NULL and cannot repeat. Most tables use a whole number id, and the database can generate it automatically.

Example
CREATE TABLE badges (
  id INTEGER PRIMARY KEY,
  label TEXT
);
INSERT INTO badges (label) VALUES ('Starter'), ('Streak'), ('Graduate');
SELECT * FROM badges;

Result

id | label
1  | Starter
2  | Streak
3  | Graduate

Exercise

Mark the identifying column.

id INTEGER PRIMARY 

Quiz Test

Can a primary key be NULL?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.