Not quite random.
A UUID looks like 32 random hex digits. One of them names the version, and the version decides what the others are made of: time, a hash, a machine, or chance.
Version 7. Milliseconds since 1970, then random bits. Sorts by creation time; the usual pick for database keys.
Field by field
What each part of the UUID above is for, and what these particular digits say.
- unix_ts_ms48 bits
Milliseconds since 1970 in UTC, enough until the year 10889. Time comes first, so sorting the text sorts the ids by when they were made. This one says
2022-02-22 19:22:22.000UTC. - ver4 bits
The version, always the 13th digit. 7 means Unix time, then random. In binary,
0111. - rand_a12 bits
Random bits, or a counter that keeps ids from the same millisecond in order.
- var2 bits
The variant: the first two bits of digit 17, always 10 in an RFC 9562 UUID. That is why digit 17 is 8, 9, a or b. Here
9is1001: the variant, then two bits of rand_b. - rand_b62 bits
Random bits.
Every version, one grid
The examples printed in RFC 9562. Whatever the version, the 13th digit names it and the 17th carries the variant.
Which one? For database keys, v7: it sorts by the time it was made. For ids that should give nothing away, v4. When the same name must always map to the same id, v5. The rest serve old systems (v1, v3), moves off v1 (v6) and layouts of your own (v8). There is no v2: RFC 9562 leaves it to DCE Security.