Introduction
A .duckdb file is a database made by DuckDB,
an analytical SQL database that, like SQLite, runs
inside the program that uses it and keeps a whole database in one file. Where SQLite is
built for many small reads and writes, DuckDB is built for queries over large tables,
and stores its data by column.
DuckDB was first released in 2019 by researchers at CWI in Amsterdam. Its storage
format changed between early releases; since version 0.10 in 2024 newer releases can
read files written by older ones. DuckDB 2.0 brought a new storage version that
older releases cannot open. Files are also given .db or
.ddb.
Structure
The file is made of fixed-size blocks. It starts with a main header, whose bytes 8 to
11 are the text DUCK, followed by the storage version number. Two database
headers come next; DuckDB writes them in turn, so one of them always points to the last
complete checkpoint.
The rest of the file holds the catalogue of schemas and tables and the table data. Each table is split into row groups, and each column of a row group is stored and compressed on its own. The headers and versions page gives the header fields and every storage version.
Not described
DuckDB documents only how to recognise a file and its storage version; the rest is in its
source code. Re-checked on 2026-11-13 against the storage documentation page and
storage_info.hpp.
Known, not yet covered
- Reference: the serialised order and offsets of the main header and database
header fields, and the block and meta-block chain, free list and checksum algorithm. They are
defined by DuckDB’s source files (the main header and database header
Write/Readfunctions, the block manager) that were not read; the header file declares the fields only. - Reference: the catalogue serialisation, row group and column segment layouts, each compression method’s format (constant, RLE, bit packing, FOR, dictionary, FSST, DICT_FSST, ALP, Chimp, Patas, Zstd) and the write-ahead log. These live in DuckDB’s source; none of them is documented in prose.
Unknown
- Reference: the meaning of the main header flags beyond bit 0 (encrypted): the header file defines only that bit.
Links
Software
Developers
- DuckDB client APIs – the DuckDB library for many languages (Python, R, Java, Node.js, Rust, Go and others)
Reference
- Storage – the DuckDB documentation on the file format and its versions