UUID Functions
UUID Functions
PostgreSQL includes one function to generate a UUID:
gen_random_uuid () uuid
The uuid-ossp module provides additional functions that implement other standard algorithms for generating UUIDs.
There are also functions to extract data from UUIDs:
uuid_extract_timestamp (uuid) timestamp with time zone
timestamp with time zone from UUID version 1. For other versions, this function returns null. Note that the extracted timestamp is not necessarily exactly equal to the time the UUID was generated; this depends on the implementation that generated the UUID.
uuid_extract_version (uuid) smallint
gen_random_uuid, this function will return 4.
PostgreSQL also provides the usual comparison operators shown in Comparison Operators for UUIDs.