MariaDB SYS_GUID() Function

In MariaDB, SYS_GUID() is a built-in function that returns a 16-byte globally unique identifier (GUID).

This function was introduced in MariaDB 10.6.1.

You can also use UUID() and UUID_SHORT() to get unique identifiers.

MariaDB SYS_GUID() Syntax

Here is the syntax of the MariaDB SYS_GUID() function:

SYS_GUID()

Parameters

The MariaDB SYS_GUID() function do not require any parameters.

Return value

The MariaDB SYS_GUID() function returns a 16-byte globally unique identifier (GUID), which is a string of length 32.

MariaDB SYS_GUID() Examples

The following example shows how to use the SYS_GUID() function to obtain a globally unique identifier.

SELECT SYS_GUID();

Output:

+----------------------------------+
| SYS_GUID()                       |
+----------------------------------+
| 47855bfba10a11edac3118c04d19fce5 |
+----------------------------------+

If you call it again, you get a different value:

SELECT SYS_GUID();

Output:

+----------------------------------+
| SYS_GUID()                       |
+----------------------------------+
| 93b21d62a10a11edac3118c04d19fce5 |
+----------------------------------+

Even if you call SYS_GUID() twice in the same statement, different values ​​will be reached:

SELECT
  SYS_GUID(),
  SYS_GUID()\G

Output:

SYS_GUID(): c32f01c6a10a11edac3118c04d19fce5
SYS_GUID(): c32f01caa10a11edac3118c04d19fce5

SYS_GUID() vs UUID() vs UUID_SHORT()

The following example shows the difference between SYS_GUID(), UUID(), and UUID_SHORT():

SELECT
  UUID_SHORT(),
  UUID(),
  SYS_GUID()\G

Output:

UUID_SHORT(): 100158760672034820
      UUID(): 152d00b1-a10d-11ed-ac31-18c04d19fce5
  SYS_GUID(): 152d00b6a10d11edac3118c04d19fce5

Conclusion

In MariaDB, SYS_GUID() is a built-in function that returns a 16-byte globally unique identifier (GUID).