Catalog Error: The table does not exist in this database
DuckDB cannot find the named table, view or table function in the catalog of the database you are connected to.
- Exception
Catalog Error
它的意義
This is DuckDB's missing-object error. The binder looked up the name in the catalog and found nothing with it: no table, no view, no table function. For a missing table the message spells out Table with name X does not exist!. A missing table function reports Table Function with name X does not exist!.
Because DuckDB is often embedded, the usual cause is not a typo but the wrong database: the application opened a fresh in-memory database, the file path resolved relative to a different working directory, or the query ran on a connection that never created the schema. Lookups are case-insensitive even for names created in double quotes, so a table created as "V07Mixed" is found by SELECT * FROM v07mixed and SELECT * FROM "v07mixed".
常見原因
- A misspelled table name. Casing does not matter, even for names created with double quotes.
- The query ran against a different database than you think, often a new in-memory one opened by default.
- A table function from an extension that is not loaded, such as
iceberg_scanwith autoloading disabled, does not bind. Built-in functions such asread_csv_autoneed no extension and fail with an IO error on a missing file, not a catalog error. - The migration that creates the table never ran on this connection.
Find the cause
-- What tables does this connection see, and from which file? SELECT database_name, schema_name, table_name, estimated_size FROM duckdb_tables(); SELECT database_name, path FROM duckdb_databases(); -- Search every catalog position of the name, including views and table functions: SELECT * FROM duckdb_tables() WHERE table_name ILIKE '%users%'; SELECT function_name FROM duckdb_functions() WHERE function_name ILIKE '%users%';
如何修正
-
List what actually exists in the connected database before rewriting the query:
SELECT table_schema, table_name, table_type FROM information_schema.tables ORDER BY 1, 2;
-
Check which database file the connection opened. An empty catalog usually means the process opened a new or in-memory database:
SELECT current_database(), database_name, path FROM duckdb_databases();
-
Qualify the name if the table lives in another attached database:
SELECT * FROM backup.users LIMIT 5;
-
Create the table if it should exist, with IF NOT EXISTS so reruns are safe:
CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY, email VARCHAR);
Other ways to handle it
If the table should exist, run the migration on this connection instead of working around it. If it should not, point the connection at the right file with an absolute path; relative paths are resolved against the process working directory, which is rarely what you expect in a service.
安全地重現問題
SELECT * FROM no_such_table; -- Catalog Error: Table with name no_such_table does not exist!
問題
The table exists in my file. Why does DuckDB say it does not?
The connection is probably not on that file. Embedded apps often open an unnamed in-memory database by default, and a relative path may have resolved elsewhere. Run SELECT * FROM duckdb_databases() to see the path of what you are connected to.
Does capitalization matter?
Names are matched case-insensitively, including names created inside double quotes. A name created as "V07Mixed" is found by any casing, quoted or not.
相關錯誤
Catalog ErrorThe table or object already existsBinder ErrorThe column is not in the FROM clauseIO ErrorA file could not be openedSQLITE_ERRORSQLite: SQL logic error42P01PostgreSQL:關聯不存在1146MySQL:資料表不存在
More catalog error errors
程式碼和訊息文字來自 DuckDB documentation。瀏覽完整的 DuckDB error list 或 搜尋每個資料庫錯誤.
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.
本頁文字與資料: CC BY 4.0,請註明出處 SQLly (sqlly.app)。 程式碼與 SQL 片段: MIT. 授權詳情 引用的錯誤訊息文字歸其資料庫廠商所有。