// ClickHouse error reference

16: NO_SUCH_COLUMN_IN_TABLE (code 16)

A write path such as ALTER, a mutation or an INSERT column list names a column the table does not have.

오류 코드
16
이름
NO_SUCH_COLUMN_IN_TABLE
카테고리
Tables, columns and metadata
오류 메시지
There is no column {column} in table {database}.{table}

의미

NO_SUCH_COLUMN_IN_TABLE (16) checks statements against the stored table schema and fails when a named column does not exist, most often in ALTER TABLE, ALTER UPDATE/DELETE mutations, INSERT INTO t (col_list) ... and materialized view definitions. A bad column in a plain SELECT is UNKNOWN_IDENTIFIER (47) instead.

일반적인 원인

  • A typo or a renamed column in an ALTER or mutation command.
  • INSERT lists a column the target table does not have, or a view's target list drifted from its source.
  • Generated SQL was written for an older schema.

Find the cause

`system.columns` for the true schema, `SHOW CREATE TABLE` for view definitions, `system.query_log` for the failed statement, and `system.mutations` shows stuck mutations with `latest_fail_reason`.

해결 방법

  1. List the columns the table actually has.

    SELECT name, type FROM system.columns WHERE database = 'my_db' AND table = 'my_table' ORDER BY position;
  2. Rewrite the mutation against the real name, or add the column first.

    ALTER TABLE my_table ADD COLUMN IF NOT EXISTS new_col String;
  3. Fix a materialized view whose target list drifted by rewriting its SELECT.

    ALTER TABLE my_mv MODIFY QUERY SELECT id, new_name FROM my_table;

Other ways to handle it

DESCRIBE TABLE my_table answers existence fast. EXISTS checks a table, never a column; generated code should query system.columns.

안전하게 재현하세요

Mutations resolve against the stored schema, so the failure comes back from the ALTER itself, not from a SELECT.

CREATE TABLE scratch_g (id UInt32) ENGINE = MergeTree ORDER BY id; then ALTER TABLE scratch_g DELETE WHERE missing_col = 1 gets code 16.

질문

Why 16 in mutations but 47 in SELECT?

SELECT column resolution reports UNKNOWN_IDENTIFIER (47) through the analyzer. DDL and mutation commands resolve against the stored schema and report 16.

The column exists on another replica?

Then the schema drifted between nodes. Compare system.columns on every replica and keep them aligned with ALTER ... ON CLUSTER.

관련 오류

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. 라이선스 세부 정보 인용된 오류 메시지 텍스트의 권리는 해당 데이터베이스 공급업체에 있습니다.