Categories:

String & Binary Functions (General) , Data Generation Functions

UUID_STRING¶

Generates either a version 4 (random) or version 5 (named) RFC 4122-compliant UUID as a formatted string.

Syntax¶

UUID_STRING()

UUID_STRING( <uuid> , <name> )
Copy

Usage Notes¶

  • UUID_STRING returns a 128-bit value, formatted as a string. For random-number generation, the 64-bit Mersenne twister known as MT19937-64 is used.

  • UUID_STRING supports generating two versions of UUIDs, both compliant with RFC 4122:

    • A version 4 (random) UUID is returned when no arguments are provided to the function.

    • A version 5 (named) UUID can be produced by providing a uuid string (known as the namespace) as the first argument and a name string as the second argument.

Examples¶

SELECT UUID_STRING();

+--------------------------------------+
| UUID_STRING()                        |
|--------------------------------------|
| 3afd051d-4bd0-4b30-8376-cf062719f090 |
+--------------------------------------+
Copy
SELECT UUID_STRING('fe971b24-9572-4005-b22f-351e9c09274d','foo');

+-----------------------------------------------------------+
| UUID_STRING('FE971B24-9572-4005-B22F-351E9C09274D','FOO') |
|-----------------------------------------------------------|
| dc0b6f65-fca6-5b4b-9d37-ccc3fde1f3e2                      |
+-----------------------------------------------------------+
Copy