AUTO_INCREMENT

A MySQL column attribute that generates the next numeric id automatically, normally on a Primary Key. When you omit the column in an INSERT INTO, the server fills it in (1, 2, ...).

sql
CREATE TABLE author (
  author_id INT PRIMARY KEY AUTO_INCREMENT
);

When to use

PP 03 Q5 uses author_id INT PRIMARY KEY AUTO_INCREMENT, so every INSERT may leave author_id out. PS 02 uses it for customer_id. It is MySQL specific; standard SQL uses GENERATED ... AS IDENTITY.

See PP 03.

Appears in

No references yet.