Documentation / SQL / Functions
Blob Functions
This section describes functions and operators for examining and manipulating BLOB values.
| Description | Concatenates two strings, lists, or blobs. Any NULL input results in NULL. See also concat(arg1, arg2, ...) and list_concat(list1, list2, ...). |
| Example 1 | 'Duck' || 'DB' |
| Result | DuckDB |
| Example 2 | [1, 2, 3] || [4, 5, 6] |
| Result | [1, 2, 3, 4, 5, 6] |
| Example 3 | '\xAA'::BLOB || '\xBB'::BLOB |
| Result | \xAA\xBB |
| Description | Converts blob to VARCHAR. Fails if blob is not valid UTF-8. |
| Example | decode('\xC3\xBC'::BLOB) |
| Result | ü |
| Description | Converts the string to BLOB. Converts UTF-8 characters into literal encoding. |
| Example | encode('my_string_with_ü') |
| Result | my_string_with_\xC3\xBC |
| Description | Converts a base64 encoded string to a character string (BLOB). |
| Example | from_base64('QQ==') |
| Result | A |
| Description | Converts blob to VARCHAR using hexadecimal encoding. |
| Example | hex('\xAA\xBB'::BLOB) |
| Result | AABB |
| Alias | to_hex |
| Description | Returns the MD5 hash of the blob as a VARCHAR. |
| Example | md5('\xAA\xBB'::BLOB) |
| Result | 58cea1f6b2b06520613e09af90dc1c47 |
| Description | Returns the MD5 hash of the blob as a HUGEINT. |
| Example | md5_number('\xAA\xBB'::BLOB) |
| Result | 94525045605907259200829535064523132504 |
| Description | Number of bytes in blob. |
| Example | octet_length('\xAA\xBB'::BLOB) |
| Result | 2 |
| Description | Returns the content from source (a filename, a list of filenames, or a glob pattern) as a BLOB. See the read_blob guide for more details. |
| Example | read_blob('hello.bin') |
| Result | hello\x0A |
| Description | Repeats the blob count number of times. |
| Example | repeat('\xAA\xBB'::BLOB, 5) |
| Result | \xAA\xBB\xAA\xBB\xAA\xBB\xAA\xBB\xAA\xBB |
| Description | Returns a VARCHAR with the SHA-1 hash of the blob. |
| Example | sha1('\xAA\xBB'::BLOB) |
| Result | 65b1e351a6cbfeb41c927222bc9ef53aad3396b0 |
| Description | Returns a VARCHAR with the SHA-256 hash of the blob. |
| Example | sha256('\xAA\xBB'::BLOB) |
| Result | d798d1fac6bd4bb1c11f50312760351013379a0ab6f0a8c0af8a506b96b2525a |
| Description | Converts a blob to a base64 encoded string. |
| Example | to_base64('A'::BLOB) |
| Result | QQ== |
| Alias | base64 |
| Description | Converts a value from binary representation to a blob. |
| Example | unbin('0110') |
| Result | \x06 |
| Alias | from_binary |
| Description | Converts a value from hexadecimal representation to a blob. |
| Example | unhex('2A') |
| Result | * |
| Alias | from_hex |
© 2025 DuckDB Foundation, Amsterdam NL