pg_attrdef
系统目录 pg_attrdef 存储列默认表达式和生成表达式。 列的主要信息存储在 pg_attribute 中。 只有显式设置了默认表达式或生成表达式的列才会在此有条目。
pg_attribute
表 52.6. pg_attrdef Columns
列类型
描述
oid oid
oid
行标识符
adrelid oid (references pg_class.oid)
adrelid
pg_class
该列所属的表
adnum int2 (references pg_attribute.attnum)
adnum
int2
attnum
列的编号
adbin pg_node_tree
adbin
pg_node_tree
列默认值或生成表达式,以 nodeToString() 表示。使用 pg_get_expr(adbin, adrelid) 可将其转换为 SQL 表达式。
nodeToString()
pg_get_expr(adbin, adrelid)