SQLite 3 reference · String Functions
SQLite HEX() Function
Return the hexadecimal form of a value's bytes (its UTF-8 text for strings). Often used to display BLOBs.
SQLite 3
Syntax
hex(X)
Parameters
| Parameter | Description |
|---|---|
X |
A BLOB or a value treated as text. |
Return value
Uppercase hex text.
Examples
SELECT hex('abc') AS text_hex, hex(x'00FF') AS blob_hex;
Output
text_hex | blob_hex 616263 | 00FF
SELECT hex(randomblob(4)) IS NOT NULL AS ok, length(hex(randomblob(16))) AS chars;
Output
ok | chars 1 | 32
Related
UNHEX()· Decode a hexadecimal string into a BLOB, the reverse of hex(). Returns NULL if the text isn't valid hex.CHAR()· Return a string made from Unicode code point numbers, such as char(72, 105) for 'Hi'. The reverse of unicode().- SQL String Functions · tutorial