Skip to main content

UNHEX

For a string argument str, UNHEX(str) interprets each pair of characters in the argument as a hexadecimal number and converts it to the byte represented by the number. The return value is a binary string.

Syntax

UNHEX(<expr>)

Aliases

Examples

SELECT UNHEX('6461746162656e64') as c1, typeof(c1),UNHEX('6461746162656e64')::varchar as c2, typeof(c2), FROM_HEX('6461746162656e64');

┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ c1 │ typeof(c1) │ c2 | typeof(c2) | from_hex('6461746162656e64') |
├───────────────────────────┼────────────────────────|──────────────────┤───────────────────|─────────────────────────────────┤
6461746162656E64 │ binary │ databend | varchar | 6461746162656E64 |
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

SELECT UNHEX(HEX('string')), unhex(HEX('string'))::varchar;

┌──────────────────────────────────────────────────────┐
│ unhex(hex('string')) │ unhex(hex('string'))::varchar
├──────────────────────┼───────────────────────────────┤
737472696E67 │ string │
└──────────────────────────────────────────────────────┘
Did this page help you?
Yes
No
Explore Databend Cloud for FREE
Low-cost
Fast Analytics
Easy Data Ingestion
Elastic Scaling
Try it today