Summary
The catalog pg_attrdef stores column default expressions and generation expressions. The main information about columns is stored in pg_attribute. Only columns for which a default expression or generation expression has been explicitly set will have an entry here.
(Description quoted from the official PostgreSQL documentation.)
Columns
The pg_attrdef system catalog exposes the following columns (names, types and descriptions are taken verbatim from the PostgreSQL documentation):
oidoid
Row identifieradrelidoidreferencespg_class.oid
The table this column belongs toadnumint2referencespg_attribute.attnum
The number of the columnadbinpg_node_tree
The column default or generation expression, in nodeToString() representation. Use pg_get_expr(adbin, adrelid) to convert it to an SQL expression.
Related catalogs
This object references the following other system catalogs:
adrelid→pg_classadnum→pg_attribute
Version applicability
Present in PostgreSQL 17, 18, 19 (verified against each release’s documentation). This is a long-standing system object that also exists in earlier PostgreSQL releases.
Related & references
Reference: PostgreSQL documentation — pg_attrdef.