# 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.

Source: https://sqlly.app/errors/clickhouse/no-such-column-in-table
Last updated: 2026-11-30
License: Text and data [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) (credit SQLly, sqlly.app); code and SQL snippets [MIT](https://opensource.org/license/mit). [Details](https://sqlly.app/license).
Note: Quoted error message text belongs to its database vendor.

- Error code: `16`
- Name: `NO_SUCH_COLUMN_IN_TABLE`
- Category: Tables, columns and metadata

Error message:

```text
There is no column {column} in table {database}.{table}
```

## What it means

`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.

## Common causes

- 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.

## How to fix it

1. List the columns the table actually has.

   ```sql
   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.

   ```sql
   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.

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

## Reproduce it safely

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

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

## How SQLly helps

SQLly's Validate SQL marks the missing column in the editor before the mutation runs, using the schema it loaded from your ClickHouse connection.

## Questions

### 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.

## Related errors

- [`47`](https://sqlly.app/errors/clickhouse/unknown-identifier): UNKNOWN_IDENTIFIER (code 47)
- [`53`](https://sqlly.app/errors/clickhouse/type-mismatch): TYPE_MISMATCH (code 53)
- [`60`](https://sqlly.app/errors/clickhouse/table-not-exists): UNKNOWN_TABLE (code 60)

The code and message text are from the [ClickHouse documentation (system.errors)](https://clickhouse.com/docs/en/operations/system-tables/errors).
