// ClickHouse error reference

60: UNKNOWN_TABLE (code 60)

The table you queried or referenced is missing from the database the query reached.

エラーコード
60
名前
UNKNOWN_TABLE
カテゴリ
Tables, columns and metadata
エラーメッセージ
Unknown table expression identifier '{table}'. In scope {query}.

意味

UNKNOWN_TABLE (60) means the server cannot resolve a table name in the current database or the one you qualified. It is the ClickHouse twin of no such table in other engines. The database is fine (that failure is UNKNOWN_DATABASE, 81); only the table name fails. When a table with that name exists in another database, the server adds Maybe you meant {database}.{table}? before the scope clause. DDL and INSERT against a missing table report Table {database}.{table} does not exist. with the same code 60.

よくある原因

  • A typo in the table name, or the wrong database in the connection string.
  • The query hit a different server or tenant where the table was never created.
  • A Distributed table points at a shard where the local table is missing, so the remote query fails with this code.

Find the cause

`SELECT currentDatabase()` to see the session default, `system.tables` for existence, `system.query_log` for the exact failed query text, and `system.clusters` when a Distributed table is involved.

修正方法

  1. List what the server actually sees and compare against your query.

    SELECT database, name FROM system.tables WHERE name ILIKE '%my_table%';
  2. Qualify the table with its database so the default database of the session stops mattering.

    SELECT count() FROM my_db.my_table;
  3. If a shard is missing its local table, create it on that shard's host before querying the Distributed table.

    CREATE TABLE my_table (id UInt64) ENGINE = MergeTree ORDER BY id;

Other ways to handle it

EXISTS TABLE my_table そして SELECT * FROM system.tables WHERE ... let the application check first. SHOW TABLES FROM my_db lists a database quickly.

安全に再現する

CREATE TABLE scratch_b (id UInt32) ENGINE = MergeTree ORDER BY id; then run SELECT * FROM scratch_b_wrong and you get code 60.

質問

Can case sensitivity cause this?

Yes. ClickHouse table, database and column names are case sensitive, so MyTable and mytable are different names.

Why does the error mention the wrong database?

Unqualified names resolve against the session default database, which may differ from the one you had in mind.

関連エラー

More tables, columns and metadata errors

コードとメッセージのテキストは、 ClickHouse documentation (system.errors)。全容は次で参照 ClickHouse error list または すべてのデータベースエラーを検索.

// エラーが減り、修正も速く

Work on ClickHouse in SQLly

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

このページのテキストとデータ: CC BY 4.0、出典は SQLly (sqlly.app) と明記してください。 コードと SQL スニペット: MIT. ライセンスの詳細 引用したエラーメッセージの文言は、各データベースベンダーに帰属します。