pg_attrdef — PostgreSQL system catalog

The PostgreSQL pg_attrdef system catalog: full column reference (names, types, descriptions), catalog relationships and version support.

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):

  • oid oid
    Row identifier
  • adrelid oid references pg_class.oid
    The table this column belongs to
  • adnum int2 references pg_attribute.attnum
    The number of the column
  • adbin pg_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:

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.