Skip to main content
The following functions are supported for generating UUIDs and extracting parts of UUIDs:
FunctionDescriptionExample
uuidv4() → UUIDGenerates a version-4 UUIDuuidv4()
=> b42410ee-132f-42ee-9e4f-09a6485c95b8
gen_random_uuid() → UUIDSame as uuidv4()
uuid_extract_timestamp(uuid) → TIMESTAMPExtracts a timestamp from a UUID of version 1 or 7.
For other versions, this function returns null.
uuid_extract_timestamp('019535d9-3df7-79fb-b466-​fa907fa17f9e'::uuid) => 2025-02-23 21:46:24.503
uuid_extract_version(uuid) → SMALLINTExtracts the version from a UUID of one of the variants described by RFC 9562.
For other variants, this function returns null.
uuid_extract_version('41db1265-8bc1-4ab3-992f-​885799a4af1d'::uuid) => 4