Syntax
BIN_TO_UUID(binary_uuid), BIN_TO_UUID(binary_uuid,swap_flag)
Purpose
BIN_TO_UUID() converts a binary UUID to a string UUID and returns the result. The value of binary_uuid must be a UUID of the VARBINARY(16) data type. The return value is a 128-bit number conforming to UUID v1. It is a utf8mb3 string that consists of five hexadecimal numbers separated with dashes. The format is the same as that of the UUID() function: aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeeeee.
- The first three numbers are generated from the low, middle, and high parts of a timestamp The high part also includes the UUID version.
- The fourth number preserves temporal uniqueness in case the timestamp value loses monotonicity (for example, due to daylight saving time).
- The fifth number is an IEEE 802 node number that provides spatial uniqueness. If no IEEE 802 node number is available, a random number can be used, but spatial uniqueness cannot be guaranteed in this case.
If the UUID argument is NULL, the return value is NULL. If any argument is invalid, an error occurs.
You can specify a single argument or two arguments in the syntax of BIN_TO_UUID().
- Specify only a binary UUID value. It is assumed that the time-low and time-high parts or the UUID value are not swapped. The returned string is in the same order as the binary argument.
- Specifies a binary UUID value and a
swap_flagvalue.- If the
swap_flagvalue is 0,the two-argument form is equivalent to the one-argument form. The returned string is in the same order as the binary argument. - If the
swap_flagvalue is 1, it is assumed that the time-low and time-high parts of the UUID value are swapped. These parts are swapped back to their original positions in the result value.
- If the
BIN_TO_UUID() is an inverse function of UUID_TO_BIN(). For more information about examples and time part swapping rules, see UUID_TO_BIN().