Declaration
UNHEX(str)
Description
Converts hexadecimal digits in the string str to bytes and returns a binary string.
The characters in the string str must be from the sets 0 to 9, A to F, and a to f. If the string contains any non-hexadecimal characters, the function returns NULL.
If str is a column of the BINARY data type and contains bytes padded with 0x00, this function also returns NULL. For the numeric parameter N, UNHEX(N) is not the inverse operation of HEX(N). In this case, you can use CONV(HEX(N),16,10) as an alternative.
In particular, you can use the --binary-as-hex parameter in the client connection string to specify that binary strings should be represented in hexadecimal.
Examples
obclient> SELECT UNHEX('4f6365616e42617365');
+-----------------------------+
| UNHEX('4f6365616e42617365') |
+-----------------------------+
| OceanBase |
+-----------------------------+
1 row in set
obclient> SELECT X'4f6365616e42617365';
+-----------------------+
| X'4f6365616e42617365' |
+-----------------------+
| OceanBase |
+-----------------------+
1 row in set