Syntax
UNHEX(str)
Purpose
You can call this function to convert hexadecimal numbers in the str string to bytes, and return a binary string.
Characters in the str string must fall in the following ranges: 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 BINARY column with any values padded with 0x00 bytes, the function also returns NULL. For a numeric parameter N, UNHEX(N) is not the reverse operation of HEX(N). In this case, you need to use CONV(HEX(N),16,10).
Note that you can specify the --binary-as-hex parameter in the string for connection with the client. This parameter indicates that a binary string is represented in the hexadecimal equivalent.
Examples
obclient> SELECT UNHEX('4f6365616e42617365');
+-----------------------------+
UNHEX('4f6365616e42617365')
+-----------------------------+
OceanBase
+-----------------------------+
1 row in set (0.01 sec)
obclient> SELECT X'4f6365616e42617365';
+-----------------------+
X'4f6365616e42617365'
+-----------------------+
OceanBase
+-----------------------+
1 row in set (0.00 sec)