The New UUID Standard: Background for Beginners

If you read about primary keys online, you will soon meet the letters UUID, and maybe "UUIDv7". This explainer gives the background so the headlines make sense, without assuming you already know how indexes work.

What a UUID is

A UUID (universally unique identifier) is a 128-bit number usually written as 36 characters, like 3f2b8c1e-9a7d-4e21-b6c3-0d5f1a2e7b90. The idea: any computer can create one without asking anyone else, and the chance of two being the same is so small that you can treat them as unique.

That makes UUIDs useful as primary keys. A primary key is the column that identifies each row, like a student number. The more familiar option is a counting number, 1, 2, 3, handed out by the database.

What changed in 2024

UUIDs come in versions, which describe how the bits are made. For years the most common was version 4, which is almost entirely random. In May 2024 the IETF, the body that publishes internet standards, published RFC 9562. It replaced the older UUID specification and formally added new versions, including version 7.

A version 7 UUID starts with a timestamp, so UUIDs created later sort after ones created earlier. The rest is random, so they stay unique.

Why people cared

Databases keep a sorted structure called an index to find rows quickly by key. Think of the index at the back of a book. Adding random keys means inserting entries all over that sorted list. Adding keys that grow over time means adding at the end, which is gentler on the database. Version 7 gives the "unique without asking" benefit of UUIDs with the "adds at the end" benefit of counting numbers.

Should a beginner care?

Not much, yet. For a first project, a counting integer is simplest:

CREATE TABLE notes (
  id    INTEGER PRIMARY KEY,   -- SQLite hands out 1, 2, 3...
  body  TEXT NOT NULL
);

UUIDs become useful when several systems create records independently, or when you do not want ids in web addresses to reveal how many records exist.

Quick comparison

Key typeLooks likeGood forWatch out for
Counting integer42Learning, most small appsReveals order and roughly how many rows exist
UUID version 4random 36 charactersCreating ids anywhereRandom order, bigger than an integer
UUID version 7starts with time, then randomCreating ids anywhere, orderedReveals roughly when it was created

Where support stands

Support depends on your tools. PostgreSQL 18 added a built-in uuidv7() function; elsewhere, libraries in most languages can generate version 7 values. Check your database and library documentation rather than assuming.

Reading the headlines

When you see "UUIDv7 is the new default" in a blog post, read it as an opinion about larger systems. The standard itself does not tell you what to use; it just defines the formats clearly. For learning, focus on what a primary key must do: be unique, never change, and never be empty. Our primary key follow-up questions cover those rules.

A free learning page for beginners. Practise on a test database, never on real customer data, and check the official documentation for your database version.

General commentary only: this page does not report specific news events and does not cite a survey or data source. Treat any trends described as unverified.

Related pages on this site