跳到主要内容

HEX

For a string argument str, HEX() returns a hexadecimal string representation of str where each byte of each character in str is converted to two hexadecimal digits. The inverse of this operation is performed by the UNHEX() function.

For a numeric argument N, HEX() returns a hexadecimal string representation of the value of N treated as a longlong (BIGINT) number.

Syntax

HEX(expr)

Arguments

ArgumentsDescription
exprThe number or string.

Examples

SELECT HEX('abc');
+------------+
| HEX('abc') |
+------------+
| 616263 |
+------------+

SELECT HEX(255);
+----------+
| HEX(255) |
+----------+
| ff |
+----------+