Search Shortcut cmd + k | ctrl + k
- Installation
- What's New in the Docs for 2.0
- Documentation
- Getting Started
- Connect
- Data Import and Export
- Overview
- Data Sources
- CSV Files
- IO
- JSON Files
- Overview
- Creating JSON
- Loading JSON
- Writing JSON
- JSON Type
- JSON Functions
- Format Settings
- Installing and Loading
- SQL to / from JSON
- Caveats
- Multiple Files
- Parquet Files
- Partitioning
- Appender
- INSERT Statements
- Lakehouse Formats
- Client APIs
- Overview
- ADBC
- C
- Overview
- Startup
- Configuration
- Query
- Data Chunks
- Vectors
- Values
- Types
- Prepared Statements
- Appender
- Table Functions
- Replacement Scans
- API Reference
- C++
- CLI
- Overview
- Arguments
- Dot Commands
- Output Formats
- Agent Mode
- Editing
- Friendly CLI
- Safe Mode
- Autocomplete
- Syntax Highlighting
- Known Issues
- Go
- Overview
- Connect
- Import Data
- Run Queries
- Handle Results
- Write User Defined Functions
- Profile and Monitor
- Troubleshoot
- Java (JDBC)
- Overview
- Connect
- Import Data
- Run Queries
- Handle Results
- Write User Defined Functions
- Profile and Monitor
- Deploy as Native Image
- Troubleshoot
- Node.js (Neo)
- ODBC
- Python
- Overview
- Data Ingestion
- Conversion between DuckDB and Python
- DB API
- Relational API
- Function API
- Types API
- Expression API
- Spark API
- API Reference
- Known Python Issues
- R
- Rust
- Overview
- Connect
- Import Data
- Run Queries
- Handle Results
- Write User Defined Functions
- Profile and Monitor
- Troubleshoot
- Wasm
- Tertiary Clients
- SQL
- Introduction
- Statements
- Overview
- ANALYZE
- ALTER TABLE
- ALTER VIEW
- ATTACH and DETACH
- CALL
- CHECKPOINT
- COMMENT ON
- CONNECT and DISCONNECT
- COPY
- CREATE INDEX
- CREATE MACRO
- CREATE SCHEMA
- CREATE SECRET
- CREATE SEQUENCE
- CREATE TABLE
- CREATE VIEW
- CREATE TRIGGER
- CREATE TYPE
- DELETE
- DESCRIBE
- DROP
- EXPORT and IMPORT DATABASE
- INSERT
- LOAD / INSTALL
- MERGE INTO
- PIVOT
- Profiling
- PREPARE, EXECUTE, and DEALLOCATE
- SELECT
- SET / RESET
- SET VARIABLE
- SHOW and SHOW DATABASES
- SUMMARIZE
- Transaction Management
- UNPIVOT
- UPDATE
- USE
- VACUUM
- Query Syntax
- SELECT
- FROM and JOIN
- WHERE
- GROUP BY
- GROUPING SETS
- HAVING
- ORDER BY
- LIMIT and OFFSET
- SAMPLE
- Unnesting
- WITH
- WINDOW
- QUALIFY
- VALUES
- FILTER
- Set Operations
- Prepared Statements
- Data Types
- Overview
- Array
- Bitstring
- Blob
- Boolean
- Date
- Enum
- Geometry
- Interval
- List
- Literal Types
- Map
- NULL Values
- Numeric
- Struct
- Text
- Time
- Timestamp
- Time Zones
- Union
- Typecasting
- Variant
- Expressions
- Overview
- CASE Expression
- Casting
- Collations
- Comparisons
- IN Operator
- Logical Operators
- Star Expression
- Subqueries
- TRY
- Functions
- Overview
- Aggregate Functions
- Array Functions
- Bitstring Functions
- Blob Functions
- Date Format Functions
- Date Functions
- Date Part Functions
- Enum Functions
- Geometry Functions
- Interval Functions
- Lambda Functions
- List Functions
- Map Functions
- Nested Functions
- Numeric Functions
- Pattern Matching
- Regular Expressions
- Struct Functions
- Text Functions
- Time Functions
- Timestamp Functions
- Timestamp with Time Zone Functions
- Union Functions
- Utility Functions
- Variant Functions
- Window Functions
- Constraints
- Indexes
- Meta Queries
- DuckDB's SQL Dialect
- Overview
- Indexing
- Friendly SQL
- Keywords and Identifiers
- Order Preservation
- PostgreSQL Compatibility
- SQL Quirks
- PEG Parser
- Samples
- Configuration
- Extensions
- Overview
- Installing Extensions
- Advanced Installation Methods
- Distributing Extensions
- Extension Repositories
- Versioning of Extensions
- Troubleshooting of Extensions
- Core Extensions
- Overview
- AutoComplete
- Avro
- AWS
- Azure
- Delta
- DuckLake
- Encodings
- Excel
- Full Text Search
- httpfs (HTTP and S3)
- Overview
- HTTP(S) Support
- Hugging Face
- S3 API Support
- S3 and AWS Authentication
- Legacy Authentication Scheme for S3 API
- Iceberg
- ICU
- inet
- jemalloc
- Lance
- Legacy Parser
- MotherDuck
- MySQL
- ODBC
- Quack
- PostgreSQL
- Spatial
- SQLite
- TPC-DS
- TPC-H
- UI
- Unity Catalog
- Vortex
- VSS
- Quack Remote Protocol
- Guides
- Overview
- Data Viewers
- Database Integration
- File Formats
- Overview
- CSV Import
- CSV Export
- Directly Reading Files
- Directly Reading DuckDB Databases
- Excel Import
- Excel Export
- JSON Import
- JSON Export
- Parquet Import
- Parquet Export
- Querying Parquet Files
- File Access with the file: Protocol
- Meta Queries
- Describe Table
- EXPLAIN: Inspect Query Plans
- EXPLAIN ANALYZE: Profile Queries
- List Tables
- Summarize
- DuckDB Environment
- Network and Cloud Storage
- Overview
- HTTP Parquet Import
- HTTP CSV Import
- S3 Parquet Import
- S3 Parquet Export
- S3 Iceberg Import
- S3 Express One
- GCS Import
- Cloudflare R2 Import
- DuckDB over HTTPS / S3
- Share a Views-Only Database
- Fastly Object Storage Import
- SeaweedFS Import
- Tigris Import
- ODBC
- Performance
- Overview
- Environment
- Import
- Schema
- Indexing
- Join Operations
- File Formats
- How to Tune Workloads
- My Workload Is Slow
- Out-of-Memory Issues
- Benchmarks
- Working with Huge Databases
- Python
- Installation
- Executing SQL
- Jupyter Notebooks
- marimo Notebooks
- SQL on Pandas
- Import from Pandas
- Export to Pandas
- Import from Numpy
- Export to Numpy
- SQL on Arrow
- Import from Arrow
- Export to Arrow
- Relational API on Pandas
- Multiple Python Threads
- Integration with Ibis
- Integration with Polars
- Integration with PyTorch
- Using fsspec Filesystems
- SQL Editors
- SQL Features
- AsOf Join
- Full-Text Search
- Graph Queries
- query and query_table Functions
- Merge Statement for SCD Type 2
- Timestamp Issues
- Snippets
- Creating Synthetic Data
- Dutch Railway Datasets
- Sharing Macros
- Analyzing a Git Repository
- Importing Duckbox Tables
- Copying an In-Memory Database to a File
- Calculating a Database Checksum
- Troubleshooting
- Glossary of Terms
- Browsing Offline
- Operations Manual
- Overview
- Migrating to DuckDB v2.0
- Backup Extension Repositories
- DuckDB's Footprint
- Installing DuckDB
- Logging
- User Agents
- Securing DuckDB
- Non-Deterministic Behavior
- Limits
- DuckDB Docker Container
- Development
- Overview
- DuckDB Repositories
- Release Cycle
- Metrics
- Profiling
- Building DuckDB
- Overview
- Build Configuration
- Building Extensions
- Statically Linking Extensions
- Android
- Linux
- macOS
- Raspberry Pi
- Windows
- Python
- R
- Troubleshooting
- Unofficial and Unsupported Platforms
- Benchmark Suite
- Testing
- Internals
- Sitemap
- Live Demo
Blob Functions
This section describes functions and operators for examining and manipulating BLOB values.
| Function | Description |
|---|---|
arg1 || arg2 |
Concatenates two strings, lists, or blobs. Any NULL input results in NULL. See also concat(arg1, arg2, ...) and list_concat(list1, list2, ...). |
base64(blob) |
Alias for to_base64. |
decode(blob[, on_error]) |
Converts blob to VARCHAR. The optional on_error parameter controls handling of invalid UTF-8: 'strict' (default, throws error), 'replace' (replaces invalid characters with ?), or 'ignore' (removes invalid characters). |
encode(string) |
Converts the string to BLOB. Converts UTF-8 characters into literal encoding. |
from_base64(string) |
Converts a base64 encoded string to a character string (BLOB). |
from_binary(value) |
Alias for unbin. |
from_hex(value) |
Alias for unhex. |
hex(blob) |
Converts blob to VARCHAR using hexadecimal encoding. |
md5(blob) |
Returns the MD5 hash of the blob as a VARCHAR. |
md5_number(blob) |
Returns the MD5 hash of the blob as a HUGEINT. |
octet_length(blob) |
Number of bytes in blob. |
read_blob(source) |
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. |
repeat(blob, count) |
Repeats the blob count number of times. |
sha1(blob) |
Returns a VARCHAR with the SHA-1 hash of the blob. |
sha256(blob) |
Returns a VARCHAR with the SHA-256 hash of the blob. |
to_base64(blob) |
Converts a blob to a base64 encoded string. |
to_hex(blob) |
Alias for hex. |
unbin(value) |
Converts a value from binary representation to a blob. |
unhex(value) |
Converts a value from hexadecimal representation to a blob. |
arg1 || arg2
| 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 |
decode(blob[, on_error])
| Description | Converts blob to VARCHAR. The optional on_error parameter controls handling of invalid UTF-8: 'strict' (default, throws error), 'replace' (replaces invalid characters with ?), or 'ignore' (removes invalid characters). |
| Example | decode('\xC3\xBC'::BLOB) |
| Result | ü |
| Example | decode('\xAA'::BLOB, 'replace') |
| Result | ? |
encode(string)
| Description | Converts the string to BLOB. Converts UTF-8 characters into literal encoding. |
| Example | encode('my_string_with_ü') |
| Result | my_string_with_\xC3\xBC |
from_base64(string)
| Description | Converts a base64 encoded string to a character string (BLOB). |
| Example | from_base64('QQ==') |
| Result | A |
hex(blob)
| Description | Converts blob to VARCHAR using hexadecimal encoding. |
| Example | hex('\xAA\xBB'::BLOB) |
| Result | AABB |
| Alias | to_hex |
md5(blob)
| Description | Returns the MD5 hash of the blob as a VARCHAR. |
| Example | md5('\xAA\xBB'::BLOB) |
| Result | 58cea1f6b2b06520613e09af90dc1c47 |
md5_number(blob)
| Description | Returns the MD5 hash of the blob as a HUGEINT. |
| Example | md5_number('\xAA\xBB'::BLOB) |
| Result | 94525045605907259200829535064523132504 |
octet_length(blob)
| Description | Number of bytes in blob. |
| Example | octet_length('\xAA\xBB'::BLOB) |
| Result | 2 |
read_blob(source)
| 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 |
repeat(blob, count)
| 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 |
sha1(blob)
| Description | Returns a VARCHAR with the SHA-1 hash of the blob. |
| Example | sha1('\xAA\xBB'::BLOB) |
| Result | 65b1e351a6cbfeb41c927222bc9ef53aad3396b0 |
sha256(blob)
| Description | Returns a VARCHAR with the SHA-256 hash of the blob. |
| Example | sha256('\xAA\xBB'::BLOB) |
| Result | d798d1fac6bd4bb1c11f50312760351013379a0ab6f0a8c0af8a506b96b2525a |
to_base64(blob)
| Description | Converts a blob to a base64 encoded string. |
| Example | to_base64('A'::BLOB) |
| Result | QQ== |
| Alias | base64 |
unbin(value)
| Description | Converts a value from binary representation to a blob. |
| Example | unbin('0110') |
| Result | \x06 |
| Alias | from_binary |
unhex(value)
| Description | Converts a value from hexadecimal representation to a blob. |
| Example | unhex('2A') |
| Result | * |
| Alias | from_hex |
© 2026 DuckDB Foundation, Amsterdam NL