UUIDs: ids made anywhere
Step 1 of 110%
Concept · step 1 of 11
An id that does not need the database
An identity column asks the database for the next number. A UUID is a 128-bit id that anyone can make, anywhere, with practically no chance of two being the same.
- Written as 36 characters, like
9fd1edd7-6c93-4b6a-9eb1-212f80fc4bad, and stored in 16 bytes, twice a bigint. - Made by the database with
DEFAULT gen_random_uuid(), or by the app, a phone or another service before the row is ever sent. - It tells nothing about how many rows there are, unlike
/orders/42.
id UUID DEFAULT gen_random_uuid() PRIMARY KEYTwo tickets on the board, each with an id nobody typed and no database had to count. The next steps show what that freedom buys and what it costs.
PostgreSQL docs: UUID functions ↗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