- Categories:
String & binary functions (Encoding/Decoding)
HEX_ENCODEÂļ
Encodes the input using hexadecimal (also âhexâ or âbase16â) encoding. The result is comprised of 16 different symbols: The numbers â0â to â9â as well as the letters âAâ to âFâ (or âaâ to âfâ, see below).
- See also:
SyntaxÂļ
HEX_ENCODE(<input> [, <case>])
ArgumentsÂļ
Required:
input
A binary or string expression to be encoded.
Optional:
case
This optional boolean argument controls the case of the letters (âAâ, âBâ, âCâ, âDâ, âEâ and âFâ) used in the encoding. The default value is
1
and indicates that uppercase letters are used. The value0
indicates that lowercase letters are used. All other values are illegal and result in an error.
ReturnsÂļ
This returns a string that contains only hexadecimal digits.
ExamplesÂļ
Encode a string:
SELECT HEX_ENCODE('Snowflake');
-------------------------+
HEX_ENCODE('SNOWFLAKE') |
-------------------------+
536E6F77666C616B65 |
-------------------------+
Encode a string using lowercase letters:
SELECT HEX_ENCODE('Snowflake',0);
---------------------------+
HEX_ENCODE('SNOWFLAKE',0) |
---------------------------+
536e6f77666c616b65 |
---------------------------+