Updated on 2023-02-08 GMT+08:00

UUID Functions

UUID functions are used to generate UUID data (see UUID Type).

uuid_generate_v1()

Description: Generates a UUID sequence number.

Return type: UUID

Example:

1
2
3
4
5
SELECT uuid_generate_v1();
           uuid_generate_v1           
--------------------------------------
 c71ceaca-a175-11e9-a920-797ff7000001
(1 row)

The uuid_generate_v1 function generates UUIDs based on the time information, cluster node ID, and thread ID that generates the sequence. Each UUID is globally unique in a cluster, but there is a low probability that a UUID is duplicated among multiple clusters.

uuid()

Description: Generates a UUID sequence number. This function is a new MySQL compatibility function in version 8.2.0 and is supported only by version 8.2.0 and later clusters.

Return type: UUID

Example:

1
2
3
4
5
SELECT uuid();
             uuid
----------------------------------
 6327dc96-f0e7-0100-f2f2-6c9ff700fffe
(1 row)

Like the uuid_generate_v1() function, the UUID is generated based on the time, cluster node ID, and thread ID that generates the sequence. The UUID is globally unique in a single cluster, but there is a low probability that the UUID is duplicate among multiple clusters.

sys_guid()

Description: Generate a sequence number that is the same as the sequence number generated by the Oracle sys_guid method.

Return type: text

Example:

1
2
3
4
5
SELECT sys_guid();
             sys_guid             
----------------------------------
 4EBD3C74A17A11E9A1BF797FF7000001
(1 row)

The data generation principle of the sys_guid function is the same as that of the uuid_generate_v1 function.