// DuckDB error reference

Serialization Error: The database file version is incompatible

DuckDB could not serialize data for a COPY, export or checkpoint, or a database file was written by an incompatible version.

Exception
Serialization Error
Categoria
Extension and feature errors
Mensagem de erro
Serialization Error: Loading a database file written by a different DuckDB version is not supported

O que significa

DuckDB database files record the storage version they were written with. A file written by a newer DuckDB cannot be opened by an older build. Since v0.10 the format is backwards compatible, so a current build reads files from older versions, but never the other way around.

The wording has changed across versions. Older builds print the classic Serialization Error: Loading a database file written by a different DuckDB version is not supported. DuckDB 2.x reports storage version numbers instead, for example IO Error: Trying to read a database file with version number 69, but we can only read versions between 64 and 68. A newer-feature file reports Serialization Error: Failed to deserialize: .... All of them mean the same mismatch between the build that wrote the file and the build that opened it.

Causas comuns

  • An app or driver pinned to an older DuckDB opened a file that a newer tool, CLI or notebook wrote.
  • Two machines, or a laptop and a container, share one file while running different DuckDB versions.
  • A CI run wrote the file with the latest build and a deployment with an older library picked it up.

Find the cause

-- Run on both the connection that fails and the one that wrote the file:
SELECT version();
-- What storage version this build checkpoints as (DuckDB 2.x):
SELECT current_setting('storage_compatibility_version') AS written_as;

Como corrigir

  1. Check the version of the build that fails, then upgrade it to at least the version that wrote the file:

    SELECT version();
  2. When both versions must stay, copy the data out with the newer build and load it with the older one:

    COPY my_table TO 'my_table.parquet' (FORMAT PARQUET);
  3. To keep sharing a file with older readers, a recent DuckDB can checkpoint against an older storage version:

    ATTACH 'compat.duckdb' (STORAGE_VERSION 'v1.4.0');

Other ways to handle it

Parquet and CSV are the interchange formats between incompatible builds, and DuckDB reads both on every version. For teams that must share database files, agree on the oldest DuckDB version in play and pin everyone to it, or keep the shared data in files rather than in a database file.

Reproduza com segurança

-- Not reproducible inside one build: the mismatch happens when the file is opened.
-- Check both sides of the handoff first:
SELECT version();

Perguntas

Can a newer DuckDB open a file from an older version?

Yes. Since v0.10 the storage format is backwards compatible, so current builds read files written by older versions.

How do I move a database to a machine that cannot be upgraded?

Export with the newer build as Parquet or CSV and load it there, or have the newer build write the file with an older storage version using ATTACH ... (STORAGE_VERSION ...).

Erros relacionados

O código e o texto da mensagem são de DuckDB documentation. Veja toda a DuckDB error list ou pesquise todos os erros do banco de dados.

// menos erros, correções mais rápidas

Work on DuckDB in SQLly

A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for DuckDB and the other databases you use.

Texto e dados desta página: CC BY 4.0, com crédito ao SQLly (sqlly.app). Código e trechos SQL: MIT. Detalhes da licença O texto citado das mensagens de erro pertence ao fornecedor do banco de dados.