웹이야기

[MySQL] HEX() 본문

D/MySQL

[MySQL] HEX()

yeon.Biju 2020. 4. 13. 11:29

MySQL 문자열 함수와 연산자

 

HEX()

   -

 

HEX(str)

HEX(N)

의 형태

 

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. (Multibyte characters therefore become more than two digits.) The inverse of this operation is performed by UNHEX() function.

 

For a numeric argument N, HEX() returns a hdxadecimal string representation of the value of N treated as a longlong(BIGINT) number. This is equivalent to CONV(N, 10, 16). The inverse of this operation is performed by CONV(HEX(N), 16, 10).

 

mysql> SELECT X'616263', HEX('abc'), UNHEX(HEX('abc'));
+-----------+------------+-------------------+
| X'616263' | HEX('abc') | UNHEX(HEX('abc')) |
+-----------+------------+-------------------+
| abc       | 616263     | abc               |
+-----------+------------+-------------------+
1 row in set (0.00 sec)

 

mysql> SELECT HEX(255), CONV(HEX(255), 16, 10) ;
+----------+------------------------+
| HEX(255) | CONV(HEX(255), 16, 10) |
+----------+------------------------+
| FF       | 255                    |
+----------+------------------------+
1 row in set (0.00 sec)


 

 

'D > MySQL' 카테고리의 다른 글

[MySQL] INSTR()  (0) 2020.04.13
[MySQL] INSERT()  (0) 2020.04.13
MySQL FROM_BASE64()  (0) 2020.04.13
[MySQL] FORMAT()  (0) 2020.04.13
[MySQL] FIND_IN_SET()  (0) 2020.04.10
Comments