Diagnostic Queries
Symptoms
A DROP COLUMN (or similar) was blocked because other objects depend on the column. PostgreSQL raises SQLSTATE 2BP01 (dependent_objects_still_exist) and lists the dependents.
- Views, constraints, indexes, or rules depend on the column.
- A DETAIL/HINT lists dependents and suggests CASCADE.
- Default behaviour is RESTRICT (block the drop).
What the server log shows
ERROR: cannot drop column amount of table orders because other objects depend on it
DETAIL: view orders_summary depends on column amount
HINT: Use DROP ... CASCADE to drop the dependent objects too.
Why PostgreSQL raises this — what the manual says
Section 5.14 Dependency Tracking:
“Almost all DROP commands in PostgreSQL support specifying CASCADE.”
PostgreSQL records inter-object dependencies in pg_depend. Dropping a column that others rely on would leave them broken, so under the default RESTRICT it blocks the drop with 2BP01 unless you cascade.
Common causes
- A view/index/constraint referencing the column.
- A rule or trigger depending on the column.
- Generated columns or defaults referencing it.
How to fix it
- Drop or adjust the dependent objects first, then drop the column.
- Use
DROP COLUMN … CASCADEif you intend to remove dependents too (review the list). - Inspect dependents before deciding (the DETAIL lists them).
Related & next steps
Reference: PostgreSQL 18 Section 5.15 “Dependency Tracking”.
Thanks — noted. This helps keep the database accurate.