Collections:
UUID_TO_BIN() - Converting UUID to Binary
How to convert a UUID (Universal Unique IDentifier) string to binary a string using the UUID_TO_BIN() function?
✍: FYIcenter.com
UUID_TO_BIN(uuid, swap) is a MySQL built-in function that
converts a UUID (Universal Unique IDentifier) string
into a given binary value of 128 bits.
The swap flag allows you to swap the first part with the second and the third parts
in the UUID string.
For example:
SELECT HEX(UUID_TO_BIN('12345678-9012-3456-7890-123456789012'));
-- +----------------------------------------------------------+
-- | HEX(UUID_TO_BIN('12345678-9012-3456-7890-123456789012')) |
-- +----------------------------------------------------------+
-- | 12345678901234567890123456789012 |
-- +----------------------------------------------------------+
SELECT HEX(UUID_TO_BIN('12345678-9012-3456-7890-123456789012', 1));
-- +-------------------------------------------------------------+
-- | HEX(UUID_TO_BIN('12345678-9012-3456-7890-123456789012', 1)) |
-- +-------------------------------------------------------------+
-- | 34569012123456787890123456789012 |
-- +-------------------------------------------------------------+
SELECT HEX(UUID_TO_BIN(UUID()));
-- +----------------------------------+
-- | HEX(UUID_TO_BIN(UUID())) |
-- +----------------------------------+
-- | 55F0F080957C11EEB1EB65D6038DBAFA |
-- +----------------------------------+
Reference information of the UUID_TO_BIN() function:
UUID_TO_BIN(uuid, swap): bin
Returns the 128-bit binary string converted from the given UUID
with the option to swap the first part with the second and the third parts.
Arguments, return value and availability:
uuid: Required. The UUID string to be converted.
swap: Optional. The default is 0. if 1 is specified, the he first part
of the UUID is swapped with the second and the third parts.
bin: Return value. The converted converted 128-bit binary string.
Available since MySQL 8.0.
⇒ MySQL Functions on System Information
⇐ UUID_SHORT() - Short 64-Bit UUID Integer
2023-12-11, 1448🔥, 0💬
Popular Posts:
What is sqlservr.exe - Process - SQL Server (SQLEX?PRESS) in SQL Server? Process sqlservr.exe is the...
How To Get a List of All Tables with "sys.tables" View in SQL Server? If you want to see the table y...
How To List All Login Names on the Server in SQL Server? If you want to see a list of all login name...
Can Date and Time Values Be Converted into Integers in SQL Server Transact-SQL? Can date and time va...
What Is Transport Network Substrate (TNS) in Oracle? TNS, Transport Network Substrate, is a foundati...