// DuckDB error reference

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
Категория
Catalog Error
Сообщение об ошибке
Catalog Error: Table with name no_such_table does not exist!

Что это значит

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_scan with autoloading disabled, does not bind. Built-in functions such as read_csv_auto need 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%';

Как исправить

  1. 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;
  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();
  3. Qualify the name if the table lives in another attached database:

    SELECT * FROM backup.users LIMIT 5;
  4. 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.

Связанные ошибки

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. Подробнее о лицензии Цитируемый текст сообщений об ошибках принадлежит производителю СУБД.