All pages
Powered by GitBook
1 of 1

Loading...

HEX

Return the hexadecimal representation. This function converts a number or string to its hexadecimal string equivalent.

Syntax

Description

If N_or_S is a number, returns a string representation of the hexadecimal value of N, where N is a longlong () number. This is equivalent to (N,10,16).

If N_or_S is a string, returns a hexadecimal string representation ofN_or_S where each byte of each character in N_or_S is converted to two hexadecimal digits. If N_or_S is NULL, returns NULL. The inverse of this operation is performed by the () function.

HEX() with an argument returns a hexadecimal representation of the underlying 16-byte binary string.

Examples

See Also

This page is licensed: GPLv2, originally from

HEX(N_or_S)
OCT()
BIGINT
CONV
UNHEX
INET6
Hexadecimal literals
UNHEX()
CONV()
BIN()
fill_help_tables.sql
SELECT HEX(255);
+----------+
| HEX(255) |
+----------+
| FF       |
+----------+

SELECT 0x4D617269614442;
+------------------+
| 0x4D617269614442 |
+------------------+
| MariaDB          |
+------------------+

SELECT HEX('MariaDB');
+----------------+
| HEX('MariaDB') |
+----------------+
| 4D617269614442 |
+----------------+
SELECT HEX(CAST('2001:db8::ff00:42:8329' AS INET6));
+----------------------------------------------+
| HEX(CAST('2001:db8::ff00:42:8329' AS INET6)) |
+----------------------------------------------+
| 20010DB8000000000000FF0000428329             |
+----------------------------------------------+