UUID functions

Devart ODBC Driver for PostgreSQL supports the following UUID functions for generating and inspecting RFC-compatible UUID values.

UUID generation functions

Function Return type Description
gen_random_uuid() uuid Generates a random version 4 UUID.
uuidv4() uuid Generates a random version 4 UUID (equivalent to gen_random_uuid).
uuidv7([shift interval]) uuid Generates a time-ordered version 7 UUID based on Unix time in milliseconds, sub-millisecond data, and random bits. An optional shift interval can adjust the embedded timestamp.

UUID extraction functions

Function Return type Description
uuid_extract_timestamp(uuid) timestamptz Extracts a timestamp with time zone from a version 1 or version 7 UUID. Returns NULL for other versions. The result may differ slightly from the original generation time depending on the UUID implementation.
uuid_extract_version(uuid) smallint Extracts the version number from a UUID that follows RFC 9562. Returns NULL for non-conforming variants (for example, UUIDs produced by gen_random_uuid() return version 4).