hex
hex
description
Syntax
VARCHAR hex(VARCHAR str)
VARCHAR hex(BIGINT num)
如果输入参数是数字,返回十六进制值的字符串表示形式;
如果输入参数是字符串,则将每个字符转化为两个十六进制的字符,将转化后的所有字符拼接为字符串输出
example
输入字符串
mysql> select hex('1');
+----------+
| hex('1') |
+----------+
| 31 |
+----------+
mysql> select hex('@');
+----------+
| hex('@') |
+----------+
| 40 |
+----------+
mysql> select hex('12');
+-----------+
| hex('12') |
+-----------+
| 3132 |
+-----------+
输入数字
mysql> select hex(12);
+---------+
| hex(12) |
+---------+
| C |
+---------+
mysql> select hex(-1);
+------------------+
| hex(-1) |
+------------------+
| FFFFFFFFFFFFFFFF |
+------------------+
keywords
HEX