Important
Self-managed SingleStore will soon transition from version 9.1 RC to version 10. This new semantic versioning scheme will provide SingleStore with finer control over engine and feature releases that were not possible with the current versioning scheme.
In the interim, SingleStore 9.1 RC can be used to preview, evaluate, and provide feedback on the new and upcoming features in SingleStore 10 prior to its general availability. Ahead of this transition, SingleStore 9.0 is recommended for production workloads, which can later be upgraded to SingleStore 10.
BIN_ TO_ UUID
On this page
The BIN_ function converts a binary UUID value to a string UUID value.
Syntax
BIN_TO_UUID(binary_uuid, swap_time)
Arguments
binary_: A binary UUID value.
swap_: A flag value that can be 0 or 1.
Return Type
VARCHAR(36)
Remarks
-
If the argument is an invalid UUID value, it returns SQL
NULL. -
BIN_can take one or two arguments.TO_ UUID -
If
swap_istime 0,BIN_is a one-argument function that returns the string format in the same order as the binary value.TO_ UUID -
If
swap_istime 1,BIN_is a two-argument function that returns the string format in a different order than the binary value.TO_ UUID It assumes that the time-part swapping is already done and swaps the time-low (first) and time-high (third) groups back to their original positions.
-
Examples
Returns the UUID in string format.
SELECT BIN_TO_UUID(SYS_GUID()) AS string_uuid_value;
+--------------------------------------+
| string_uuid_value |
+--------------------------------------+
| c591b267-59a8-4d8c-89de-f16c5951bf31 |
+--------------------------------------+SYS_ returns a new GUID in every call, the output may differ if called multiple times.
Returns the UUID in string format before and after swapping the time-part.
SELECT UUID() INTO @uuid;SELECT @uuid;
+--------------------------------------+
| @uuid |
+--------------------------------------+
| 08f2a3da-4561-4880-a528-0ac0bf15c52d |
+--------------------------------------+SELECT UUID_TO_BIN(@uuid,0) INTO @binary_uuid;SELECT UUID_TO_BIN(@uuid,1) INTO @binary_uuid_swap;SELECT BIN_TO_UUID(@binary_uuid,0) AS result;
+--------------------------------------+
| result |
+--------------------------------------+
| 08f2a3da-4561-4880-a528-0ac0bf15c52d |
+--------------------------------------+SELECT BIN_TO_UUID(@binary_uuid,1) AS result;
+--------------------------------------+
| result |
+--------------------------------------+
| 45614880-a3da-08f2-a528-0ac0bf15c52d |
+--------------------------------------+SELECT BIN_TO_UUID(@binary_uuid_swap,0) AS result;
+--------------------------------------+
| result |
+--------------------------------------+
| 48804561-08f2-a3da-a528-0ac0bf15c52d |
+--------------------------------------+SELECT BIN_TO_UUID(@binary_uuid_swap,1) AS result;
+--------------------------------------+
| result |
+--------------------------------------+
| 08f2a3da-4561-4880-a528-0ac0bf15c52d |
+--------------------------------------+Last modified: