Table 9.45 shows the PostgreSQL™ functions that can be used to generate UUIDs.
Table 9.45. UUID Generation Functions
Function Description Example(s) |
|---|
Generates a version 4 (random) UUID
|
Generates a version 7 (time-ordered) UUID. The timestamp is
computed using UNIX timestamp with millisecond precision +
sub-millisecond timestamp + random. The optional
parameter
|
The uuid-ossp module provides additional functions that implement other standard algorithms for generating UUIDs.
Table 9.46 shows the PostgreSQL™ functions that can be used to extract information from UUIDs.
Table 9.46. UUID Extraction Functions
Function Description Example(s) |
|---|
Extracts a timestamp with time zone from a UUID of version 1 or 7. 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.
|
Extracts the version from a UUID of one of the variants described by
RFC
9562. For other variants, this function returns null.
For example, for a UUID generated
by
|
PostgreSQL™ also provides the usual comparison operators shown in Table 9.1 for UUIDs.
See Section 8.12 for details on the data type uuid in PostgreSQL™.