DuckDB documents how to identify a database file and its storage version (the
Storage page), but not
the layout beyond the first bytes; that is defined by DuckDB’s source code,
storage_info.hpp
(read 2026-11-13), which declares the fields but not their exact serialised order.
Fields taken from the source are marked so.
Main header
| Offset | Size | Field |
|---|---|---|
0 | 8 | Checksum of the main header (docs). The source calls these 8 bytes the block header. |
8 | 4 | Magic 44 55 43 4B, DUCK. |
12 | 8 | Version number: the storage version (see versions), or 999 in files written in DuckDB 2.0’s format. |
| … | … | Source: four 8-byte flags (flag 1 = encrypted database), 32-byte library version text, 32-byte library source hash, and for encrypted files the encryption metadata (8 bytes: cipher at byte 2, encryption version at byte 3), a 16-byte database identifier and an encrypted 8-byte canary (DUCKKEY) with its 12-byte nonce and 16-byte tag. Their order is not stated in the header file. |
The documentation suggests hexdump -n 20 -C file.duckdb to see the
magic and version. The version in the header can be older than the format the file
has since been upgraded to; the reliable way is to attach the file read-only and
read the storage_version tag from duckdb_databases().
The documentation’s example, the first 20 bytes of a file:
00000000 ac a3 60 b1 80 cb c3 8e 44 55 43 4b e7 03 00 00 |..`.....DUCK....|
00000010 00 00 00 00 |....|
The first 8 bytes are the checksum, then DUCK (the magic at offset 8,
MAGIC_BYTE_OFFSET = the block header size), then the version number as a
uint64: E7 03 is 999, the value of files in the v2.0.0 format (the source
calls it DEPRECATED; “main header storage version is now deprecated”).
In the source the encryption canary text is DUCKKEY, the encryption key length
32 bytes, the AES nonce 12 bytes (16 in the deprecated form), the IV 16 bytes (12-byte nonce
plus a 4-byte counter) and the tag 16 bytes. The main header class also keeps an
encryption_version byte, and VERSION_NUMBER,
VERSION_NUMBER_LOWER and VERSION_NUMBER_UPPER are the default and the
bounds of the readable storage format (declared in the header, their values are not given there).
An example error from the documentation: a file with version 69 opened by DuckDB 1.5.6 says
“we can only read versions between 64 and 68”; 1.5.5 and earlier report 999.
Constants from the source
| Name | Value |
|---|---|
DEFAULT_ROW_GROUP_SIZE | 122,880 rows (a multiple of the vector size and at least one vector); MAX_ROW_GROUP_SIZE 230. The row group size can be set with the ATTACH option ROW_GROUP_SIZE. |
INVALID_BLOCK | −1; the maximum block id is 262 (MAXIMUM_BLOCK). |
| Block allocation size | default 262,144 (a power of two); minimum 16,384 (the smallest size tested), maximum 262,144 (the largest currently supported). |
| Block header size | 8 bytes by default (sizeof(idx_t)); 40 bytes for encrypted blocks (DEFAULT_ENCRYPTION_BLOCK_HEADER_SIZE); at most 128; the encrypted buffer header default is 32 bytes. A block’s usable size is the allocation size minus the header size (262,136 by default). |
SECTOR_SIZE | 4,096 (the disk sector size, needed for direct IO). |
FILE_HEADER_SIZE | 4,096. |
The active database header is the one with the higher iteration count; a checkpoint switches the active
header by raising its count. Blocks beyond block_count in a file larger than
block size × block_count are implicitly part of the free list.
Compatibility and storage version options
- DuckDB 0.10 was the first release with backward compatibility in the storage format: it reads files from 0.9, and later releases are meant to read all earlier files. Forward compatibility (an older release reading newer files) is best effort and may be partly broken.
- Releases 1.0 to 1.5 create files with version 64 (the v1.0.0 format); from 2.0 new files get version 69 (v2.0.0). Releases before 2.0 cannot open the v2.0.0 format.
- The v2.0.0 format loads column metadata lazily (wide tables and large indexes open faster and use
less memory), enables
DICT_FSSTby default, stores row deletions more compactly and validates data more strictly when reading. - Since 1.2.0 the
STORAGE_VERSIONoption ofATTACH(or the CLI-storage-versionargument) sets the minimum DuckDB version that should be able to read the file; thestorage_compatibility_versionsetting does the same, withlatestor a name such asv1.4.0. The tagstorage_version=v2.0.0+induckdb_databases()shows it. - To move a file between formats:
EXPORT DATABASEwith the old release thenIMPORT DATABASEwith the new one, or attach the file andCOPY FROM DATABASEinto a new file with an explicit older storage version.
The source also names a deprecated serialisation version, separate from the storage version: 0.10.0 to 0.10.2 = 1; 0.10.3 and 1.0.0 = 2; 1.1.x = 3; 1.2.x = 4; 1.3.x = 5; 1.4.x = 6; 1.5.x = 7; 2.0.x = 8; 2.1.0 = 9 (the latest). The source lists each release’s storage version from 0.0.4 to 2.1.0; 0.0.4 to 0.2.1 are all 1, 0.2.2 is 4, 0.9.0 to 1.1.3 are 64.
Database headers
From the source. Headers are 4,096 bytes (FILE_HEADER_SIZE), kept small
so they are written almost atomically. The main header comes first, then two
database headers. The iteration count rises by 1 at each checkpoint.
| Field (source order) | Type | Meaning |
|---|---|---|
iteration | uint64 | Checkpoint counter. |
meta_block | idx_t | Pointer to the first meta block. |
free_list | idx_t | Pointer to the block holding the free list. |
block_count | uint64 | Blocks in the file as of this header; blocks beyond are free. |
block_alloc_size | idx_t | Block allocation size: 16,384 to 262,144 bytes; 262,144 by default. |
vector_size | idx_t | The vector size of the file. |
storage_compatibility | StorageVersion | The storage compatibility version. |
Each block has an 8-byte header by default (larger for encrypted files: 40 bytes). Table data is split into row groups of 122,880 rows by default, each column of a row group stored in segments with its own compression.
Storage versions
| Storage version | DuckDB releases |
|---|---|
| 70 | 2.1 (in the source as V2_1_0; not yet in the documentation’s table) |
| 69 | 2.0 |
| 68 | 1.5 |
| 67 | 1.4 |
| 66 | 1.3 |
| 65 | 1.2 |
| 64 | 0.9, 0.10, 1.0, 1.1 |
| 51 | 0.8 |
| 43 | 0.7 |
| 39 | 0.6 |
| 38 | 0.5 |
| 33 | 0.3.3, 0.3.4, 0.4.0 (the source also names 0.3.5) |
| 31 | 0.3.2 |
| 27 | 0.3.1 |
| 25 | 0.3.0 |
| 21 | 0.2.9 |
| 18 | 0.2.8 |
| 17 | 0.2.7 |
| 15 | 0.2.6 |
| 13 | 0.2.5 |
| 11 | 0.2.4 |
| 6 | 0.2.3 |
| 4 | 0.2.2 |
| 1 | 0.2.1 and earlier |
From 0.10, newer releases aim to read files from older ones; reading newer files in
older releases is best effort only. Releases 1.0 to 1.5 write version 64 by default,
so that older releases can still read the files, unless a newer
STORAGE_VERSION (1.2 and later) or storage_compatibility_version
is chosen. DuckDB 2.0 writes version 69 by default, which releases before 2.0 cannot
open.
Column compression
The documentation lists the compression methods: constant encoding, run-length
encoding, bit packing, frame of reference, dictionary encoding, FSST, ALP, Chimp,
Patas and Zstd. Which are available depends on the storage version; DuckDB 2.0
enables DICT_FSST by default.
Write-ahead log
Neither the storage documentation page nor storage_info.hpp describes a
write-ahead log or any file other than the database file (the header comments mention a
checkpoint, which switches the active database header), so nothing is stated about one
here. Its layout, if any, is not in the sources read.