Skip to main content
Version: V1.0.0

IS_UUID

Syntax​

IS_UUID(string_uuid)

Description​

Returns 1 if the parameter is a valid UUID string, 0 if it is not, and NULL if the parameter is NULL. A valid UUID string is one that can be parsed. This means it has the correct length and contains only allowed characters (hexadecimal digits and optional hyphens and braces). The most common format is:

aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee

The following format is also allowed:

aaaaaaaabbbbccccddddeeeeeeeeeeee
{aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee}

Examples​

SELECT IS_UUID('6ccd780c-abcd-1026-9564-5b8c656024db');
+-------------------------------------------------+
| IS_UUID('6ccd780c-abcd-1026-9564-5b8c656024db') |
+-------------------------------------------------+
| 1 |
+-------------------------------------------------+
1 row in set (0.001 sec)

SELECT IS_UUID('6CCD780C-ABCD-1026-9564-5B8C656024DB');
+-------------------------------------------------+
| IS_UUID('6CCD780C-ABCD-1026-9564-5B8C656024DB') |
+-------------------------------------------------+
| 1 |
+-------------------------------------------------+
1 row in set (0.001 sec)

SELECT IS_UUID('6ccd780cabcd102695645b8c656024db');
+---------------------------------------------+
| IS_UUID('6ccd780cabcd102695645b8c656024db') |
+---------------------------------------------+
| 1 |
+---------------------------------------------+
1 row in set (0.001 sec)

SELECT IS_UUID('{6ccd780c-abcd-1026-9564-5b8c656024db}');
+---------------------------------------------------+
| IS_UUID('{6ccd780c-abcd-1026-9564-5b8c656024db}') |
+---------------------------------------------------+
| 1 |
+---------------------------------------------------+
1 row in set (0.001 sec)

SELECT IS_UUID('6ccd780c-abcd-1026-9564-5b8c6560');
+---------------------------------------------+
| IS_UUID('6ccd780c-abcd-1026-9564-5b8c6560') |
+---------------------------------------------+
| 0 |
+---------------------------------------------+
1 row in set (0.001 sec)

SELECT IS_UUID(RAND());
+-----------------+
| IS_UUID(RAND()) |
+-----------------+
| 0 |
+-----------------+
1 row in set (0.001 sec)