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 to enhance Oracle compatibility.
Syntax
The syntax goes like this:
SYS_GUID()
So, no arguments are required (or accepted).
Example
Here’s an example to demonstrate:
SELECT SYS_GUID();
Result:
+----------------------------------+ | SYS_GUID() | +----------------------------------+ | FADA81BECD6E11EB8F750800270503A7 | +----------------------------------+
If I call it another time, I get a different value:
SELECT SYS_GUID();
Result:
+----------------------------------+ | SYS_GUID() | +----------------------------------+ | 0BE2DEE4CD6F11EB8F750800270503A7 | +----------------------------------+
Compared to the UUID()
Function
The result returned by SYS_GUID()
is similar to the one returned by the UUID()
function, except that SYS_GUID()
doesn’t include the hyphen symbol (-
) in the result (whereas, UUID()
does).
Here’s a comparison of the two:
SELECT
UUID(),
SYS_GUID();
Result:
+--------------------------------------+----------------------------------+ | UUID() | SYS_GUID() | +--------------------------------------+----------------------------------+ | 9e795ffc-cd71-11eb-8f75-0800270503a7 | 9E796001CD7111EB8F750800270503A7 | +--------------------------------------+----------------------------------+
There’s also a UUID_SHORT()
function that returns a short UUID as a 64-bit unsigned integer.
No Arguments
As mentioned, SYS_GUID()
doesn’t accept any arguments. Here’s what happens when I pass an argument:
SELECT SYS_GUID(3);
Result:
ERROR 1582 (42000): Incorrect parameter count in the call to native function 'SYS_GUID'