cannot alter type of a column used by a view or rule

SQLSTATE 0A000 condition feature_not_supported class 0A — Feature Not Supported severity ERROR
Reproduced & verified on PostgreSQL 14.23, 15.18, 16.14, 17.10 and 18.4 — identical message on every version.
Last reviewed 30 May 2025 · Reproduced live with the SQL on this page.

Symptoms

An ALTER COLUMN … TYPE was blocked because a view or rule depends on the column. PostgreSQL does not support altering such a column’s type in place and raises SQLSTATE 0A000 (feature_not_supported).

What the server log shows

ERROR:  cannot alter type of a column used by a view or rule
DETAIL:  rule _RETURN on view orders_summary depends on column "amount"

Why PostgreSQL raises this — what the manual says

As the ALTER TABLE reference (SET DATA TYPE) explains:

When a column’s type changes, PostgreSQL automatically reparses dependent indexes and simple table constraints, but it cannot rewrite the stored definitions of views or rules that reference the column, so the ALTER is rejected until those dependent objects are dropped or recreated.

Views and rules store a fixed reference to the column’s type. Changing that type would invalidate them, and PostgreSQL cannot rewrite them automatically, so it blocks the change with 0A000.

Common causes

How to fix it

  1. Drop the dependent view(s)/rule(s), alter the column, then recreate them.
  2. Script the drop/recreate in one transaction to minimize disruption.
  3. Inspect dependencies via pg_depend before altering.

Related & next steps

Reference: PostgreSQL 18 — ALTER TABLE.