• DuckDB
  • databases
  • SQL
  • upgrades

DuckDB 2.0 files cannot be opened by 1.x: plan the upgrade around storage versions

DuckDB 1.4 LTS support ended on November 17, 2026, and DuckDB 2.0 writes new database files in a format older versions cannot read. What a storage version is, how to check one, three safe upgrade orders, and the SQL changes tested on 1.4.5 and 2.0.1.

Imagine two scripts that share one DuckDB file. A nightly job, pinned to DuckDB 1.4, loads sales data into sales.db. A colleague’s notebook reads the same file for a dashboard. One day the colleague runs pip install -U duckdb, gets 2.0.1, and recreates sales.db from scratch to test something. The next night the job fails:

IO Error: Trying to read a database file with version number 999, but we can only read versions between 64 and 67.
The database file was created with an newer version of DuckDB.

Nothing is corrupted. The file was written in DuckDB 2.0’s new storage format, and DuckDB 1.4 cannot read it. With DuckDB 1.4 LTS reaching the end of its community support on November 17, 2026, many projects are making this move now. DuckDB 2.0.1 announcement This article explains what a storage version is, which combinations of versions and files work, how to check a file, and how to order an upgrade so no reader is left behind. Every result below was produced with the Python packages duckdb==1.4.5 and duckdb==2.0.1 on Linux.

Concepts you need first

DuckDB is a database engine that runs inside your program (a Python script, a command-line shell, an app) instead of as a separate server. A DuckDB database is usually a single file, such as sales.db, which makes it easy to share between scripts.

The bytes inside that file follow a layout, and the layout has a number: the storage version. DuckDB 1.4.x can read and write storage versions up to 67, and 1.5.x up to 68, but by default every 1.x release from 1.0 to 1.5 creates new files in version 64, the format of DuckDB 1.0. DuckDB 2.0 creates new files in version 69, the v2.0.0 format. Storage versions That is why the 1.4.5 error above says it can read “versions between 64 and 67”. It reports the 2.0 file as “999” rather than 69; whatever the number, the message means the file is newer than this DuckDB can read.

Two words describe which program can read which file:

  • Backward compatibility: a newer DuckDB reads files written by an older one. DuckDB aims for this for every file since version 0.10.
  • Forward compatibility: an older DuckDB reads files written by a newer one. DuckDB treats this as best effort, and DuckDB 2.0’s format breaks it: DuckDB versions before 2.0 cannot read database files that use the v2.0.0 storage format. Storage documentation

LTS means long-term support: a release line that receives fixes for an extended period. DuckDB 2.0 is an LTS line supported until at least October 2027. The project also extended DuckDB 1.5 support to March 2027. DuckDB 2.0.0 announcement

What actually happens: four cases

The key rule is that DuckDB 2.0 does not silently convert an existing file. It keeps writing an old file in that file’s own format. Only new files get the new format. I checked this with four files:

File Created by Opened by DuckDB 1.4.5?
old.db 1.4.5 yes
old.db after 2.0.1 inserted a row 1.4.5, then 2.0.1 yes, and it sees the new row
new.db 2.0.1, defaults no: the error shown above
compat.db 2.0.1 with STORAGE_VERSION 'v1.4.0' yes

So the danger is not “2.0 touched my file”. The danger is “2.0 created my file”, which happens whenever a script deletes and rebuilds a database, or a new environment starts from an empty directory.

Step 1: check a file’s storage version

Do not guess from file headers; let DuckDB read them. Run this with the newest DuckDB you have, because only it can open every file. It attaches each file read-only, so nothing changes on disk.

import duckdb  # 2.0.1

con = duckdb.connect()
for name in ["old", "new", "compat"]:
    con.execute(f"ATTACH '{name}.db' AS {name} (READ_ONLY)")
print(con.execute("""
    SELECT database_name, tags['storage_version']
    FROM duckdb_databases()
    WHERE database_name IN ('old', 'new', 'compat')
    ORDER BY 1
""").fetchall())

Output on my files:

[('compat', 'v1.4.0+'), ('new', 'v2.0.0+'), ('old', 'v1.0.0+')]

The tag shows the oldest DuckDB version that can open the file; v2.0.0+ means only 2.0 and later can. A file created by DuckDB 1.4.5 with default settings reports v1.0.0+, not v1.4.0+, because, as noted above, 1.x creates new files in the DuckDB 1.0 format (version 64) unless told otherwise. DuckDB 2.0 changes that default to its own newest format. Storage documentation

Step 2: choose an upgrade order

Write down every program that opens each shared file: scheduled jobs, notebooks, dashboards, the DuckDB command-line shell, a page using DuckDB-Wasm (DuckDB compiled to run inside the browser). Then pick one of three orders.

A. Upgrade every reader first, then let files move to 2.0. This is the simplest when you control all programs. Once nothing older than 2.0 opens the file, the format no longer matters. Convert existing files later if you want the new format (step 3).

B. Upgrade writers to 2.0 but keep files readable by 1.x. Use this when some readers cannot move yet, for example a tool that bundles its own DuckDB. Tell 2.0 which storage version to write when it creates a file:

con = duckdb.connect()
con.execute("ATTACH 'compat.db' (STORAGE_VERSION 'v1.4.0')")
con.execute("CREATE TABLE compat.t AS SELECT 1 AS x")

The same choice can be made for a whole connection with the storage_compatibility_version setting, or on the command line with duckdb my.db -storage-version v1.5.6. Migration guide The file then cannot use features that only exist in the newer format, such as those listed under “What’s New in the v2.0.0 Format” in the storage documentation; that is the price of compatibility.

C. Keep 1.x everywhere until a planned switch. If you cannot test now, staying on DuckDB 1.5 (supported to March 2027) buys time. Staying on 1.4 now means running a line that no longer gets community fixes.

Step 3: convert a file to the 2.0 format, when you want to

Converting rewrites the data into a new file; the original stays as it was. With 2.0, attach the old file read-only, attach a new file, and copy everything across:

con = duckdb.connect()  # 2.0.1
con.execute("ATTACH 'old.db' AS src (READ_ONLY)")
con.execute("ATTACH 'converted.db' AS dst")
con.execute("COPY FROM DATABASE src TO dst")
print(con.execute("SELECT count(*) FROM dst.sales").fetchall())

This printed [(1001,)], the same count as the source, and converted.db reported v2.0.0+. The migration guide’s main method is different: EXPORT DATABASE with the old version, then IMPORT DATABASE with 2.0, which passes the data through an intermediate folder of plain files. COPY FROM DATABASE, used above, needs only DuckDB 2.0 because 2.0 can read 1.x files. Compare row counts for every table before you replace the original file, and keep the original until every reader runs 2.0.

Step 4: test the SQL and Python changes

The file format is only half of the upgrade. DuckDB 2.0 also changes some behavior, listed in the migration guide. I ran the same statements on both versions:

Statement 1.4.5 2.0.1
SELECT list_transform([1,2,3], x -> x+1) [2, 3, 4] Binder Error: Deprecated lambda arrow (->) detected…
SELECT list_transform([1,2,3], lambda x: x+1) [2, 3, 4] [2, 3, 4]
SELECT 1 // 0 NULL Invalid Input Error: Division by zero
SELECT 'abc' ~ 'b' false true (partial match)
SELECT 2 * 3! 720 12

A few explanations. A lambda is a small inline function, here “add one to each element”; 2.0 wants the lambda x: … form, and the old arrow comes back only with SET lambda_syntax = 'enable_single_arrow' until 2.1 removes it. // is integer division: wrap it in TRY(…) if you want the old NULL. The ~ operator (regular-expression match) now finds a pattern anywhere in the text, and ! (factorial) now binds before *. Each of these changes the result without any error when the old behavior was relied on, so search your SQL for ->, //, ~ and !.

Two more documented changes also showed up in my tests:

  • Errors inside a transaction. A transaction groups statements so they succeed or fail together. In 1.4.5, after a Catalog Error (for example, querying a table that does not exist) inside BEGIN … , the next INSERT still worked. In 2.0.1 it failed with TransactionContext Error: Current transaction is aborted (please ROLLBACK). Code that catches an error and carries on inside a transaction must now roll back first, or set default_transaction_invalidation_policy = 'SYNTACTIC_ERRORS_DO_NOT_INVALIDATE' to get the old behavior. Migration guide
  • Python API. In the 2.0 Python package, a relation (the query object returned by con.sql(…)) no longer has fetchone(); the error message suggests rel.limit(1).fetchall(). I hit this in my own test script. Use con.execute(…).fetchone() when you want row-by-row reading. The 2.0 Python package also requires Python 3.11 or newer. Python migration notes

If you are moving to 2.0.0 rather than 2.0.1, note that 2.0.1 also fixes a bug where 2.0.0 could miss rows with NULL values when filtering tables in files written by 1.x, and restores 1.x behavior for UPDATE … FROM and MERGE when several source rows match one target row: the target is updated once per match, so its final value can be non-deterministic. Avoid queries where several source rows match one target. Go straight to 2.0.1 or later. DuckDB 2.0.1 announcement

Common mistakes

  • Testing on a copy that 2.0 created from scratch and then copying that file to machines with 1.x. Check the storage_version tag before you ship a file.
  • Assuming “it opened fine in 2.0” means it is still 1.x-readable. That holds only if 2.0 did not create the file, or created it with an explicit older STORAGE_VERSION. A rebuilt file is a new file, so check the tag instead.
  • Reading the error as corruption. The “version number 999” message from 1.4.5 means “newer format”, not damage. The fix is a newer reader or a file written with an explicit storage version.
  • Upgrading Python and the CLI separately. Each client bundles its own DuckDB, so a notebook on 2.0 and a shell on 1.4 on the same laptop are two different versions.

Conclusion

DuckDB 2.0 reads and writes your existing 1.x files without changing their format, but any file it creates is unreadable by 1.x. Before upgrading, list every program that opens each shared file and check each file’s storage_version tag. Then upgrade all readers first, or have 2.0 write files with STORAGE_VERSION set to the oldest reader’s version, and convert files with COPY FROM DATABASE only when no 1.x reader remains. Run your SQL against 2.0.1 before the switch, because lambdas, integer division, regular-expression matching and transaction errors now behave differently.

If you weigh support windows across runtimes, the same reasoning applies to choosing between Node.js LTS lines: the LTS end date tells you when to move, and your own tests tell you whether you can.

Written by Duy Pham Independent developer. I build the apps on this site and write about how they work.

More about me