xxxxxxxx-xxxx-7xxx-xxxx-xxxxxxxxxxxx format, where the version field is always 7.
This function is non-deterministic. Two calls to this function generate two different UUIDs.
Syntax
Return value
Returns a value of the VARCHAR type.Examples
Text
UUID v7 Format
UUID v7 follows RFC 9562 specification with the following structure:- 48 bits: Unix timestamp in milliseconds (time-ordered component).
- 4 bits: Version field, constant value
7. - 12 bits: Random data
- 2 bits: Variant field (RFC 4122)
- 62 bits: Random data
Benefits
- Time-ordered: UUIDs generated later will sort after earlier ones.
- Improved Index Performance: Better locality in B-tree indexes.
- Reduced Fragmentation: Sequential inserts cause less page splits.
- Unique: Random bits ensure uniqueness even within the same millisecond.