cannot use column references in default expression
Symptoms
A column DEFAULT expression referenced another column, which PostgreSQL does not support. It raises SQLSTATE 0A000 (feature_not_supported).
- A DEFAULT expression referenced a table column.
- Defaults must be constant-ish, not depend on other columns.
- Use a generated column or trigger instead.
What the server log shows
ERROR: cannot use column references in default expression
Why PostgreSQL raises this — what the manual says
As Section 5.2 Default Values explains:
The DEFAULT expression referenced another column of the table, which is not permitted because defaults are computed without access to the rest of the row; use a generated column or trigger for cross-column logic.
A column DEFAULT is evaluated before the row’s other values are known, so it cannot reference sibling columns. Such a reference is unsupported and PostgreSQL reports 0A000.
Common causes
- A DEFAULT clause referencing another column.
- Trying to derive one column’s default from another.
- Porting a schema from a database with different default rules.
How to fix it
- Use a generated column:
GENERATED ALWAYS AS (…) STORED. - Compute the value in a BEFORE INSERT/UPDATE trigger.
- Set the value explicitly in the application or query.
Related & next steps
Reference: PostgreSQL 18 Section 5.4 “Default Values”.