Ids the database makes, and keys of two columns
Step 1 of 110%
Concept · step 1 of 11
Let the database make the id
Writing ids by hand means the application has to know which one is next. An identity column makes the database do it.
GENERATED ALWAYS AS IDENTITYgives each new row the next number, without being asked.- ALWAYS means the application cannot supply its own. the database owns the column.
- Numbers come from a sequence and are never handed out twice, even when an insert fails.
id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEYAda and Linus were inserted with only a name, and got 1 and 2. The ID badge on the board marks a column the database fills in.
PostgreSQL docs: CREATE TABLE, identity columns and PRIMARY KEY ↗Starting a real database in your browser
It is called PostgreSQL. The first time it downloads about 5 MB; after that it is kept, and starts faster.
PostgreSQL running in your browser