uuid() function
Purpose: Returns a universal unique identifier, a 128-bit value encoded as a string with groups of hexadecimal digits separated by dashes.
Return type: string
Ascending numeric sequences of type BIGINT are often used
as identifiers within a table, and as join keys across multiple tables.
The uuid() value is a convenient alternative that does not
require storing or querying the highest sequence number. For example, you
can use it to quickly construct new unique identifiers during a data import job,
or to combine data from different tables without the likelihood of ID collisions.
-- Each call to uuid() produces a new arbitrary value.
select uuid();
+--------------------------------------+
| uuid() |
+--------------------------------------+
| c7013e25-1455-457f-bf74-a2046e58caea |
+--------------------------------------+
-- If you get a UUID for each row of a result set, you can use it as a
-- unique identifier within a table, or even a unique ID across tables.
select uuid() from four_row_table;
+--------------------------------------+
| uuid() |
+--------------------------------------+
| 51d3c540-85e5-4cb9-9110-604e53999e2e |
| 0bb40071-92f6-4a59-a6a4-60d46e9703e2 |
| 5e9d7c36-9842-4a96-862d-c13cd0457c02 |
| cae29095-0cc0-4053-a5ea-7fcd3c780861 |
+--------------------------------------+