The GENUUID function generates a Version 7 (time-ordered, random) UUID, and returns a new UUID. You can specify the output format:
- BINARY: Returns a 32-character hexadecimal string.
- FORMAT: Returns a 36-character string in the standard 8-4-4-4-12 UUID format.
If the function returns NULL, a fatal internal error has occurred.
Note: Version 7 UUIDs are designed for improved database locality compared to Version 4 UUIDs. The hexadecimal output may use lowercase letters. Use the
FORMAT option for compatibility with external UUID parsers.Category
Change Data Capture
Syntax
GENUUID () | GENUUID ('BINARY') | GENUUID ('FORMAT')
Parameters and Description
| Parameter | Description |
|---|---|
| BINARY (optional) | Returns a 32-character lowercase hexadecimal string without hyphens. This is the default format. |
| FORMAT (optional) | Returns a 36-character UUID in RFC-9562 style, including hyphens. |
- If you specify the optional "FORMAT" argument, the UUID will be returned in the standard 36-character string format. For example:
"f81d4fae-7dec-11d0-a765-00a0c91e6bf6" - If you do not specify the "FORMAT" argument, the UUID will be returned as a simple 32-character string, which is a hexadecimal representation of the 16-byte binary UUID. For example:
f81d4fae7dec11d0a76500a0c91e6bf6