.. _postgresql_pg_attrdef:

pg_attrdef
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

pg_attrdef存储列的默认值。列的主要信息存储在pg_attribute。只有那些显式指定了一个默认值的列才会在这个视图中有一个项。

.. table:: pg_attrdef 列
      :widths: 3, 2, 4
      :class: longtable
      
      +---------+--------------+------------------------------------------------------------------------------------+
      | 名称    | 类型         | 描述                                                                               |
      +=========+==============+====================================================================================+
      | oid     | oid          | 行标识符                                                                           |
      +---------+--------------+------------------------------------------------------------------------------------+
      | adrelid | oid          | 该列所属的表                                                                       |
      +---------+--------------+------------------------------------------------------------------------------------+
      | adnum   | int2         | 列号                                                                               |
      +---------+--------------+------------------------------------------------------------------------------------+
      | adbin   | pg_node_tree | 列的默认值，以nodeToString()表示。用pg_get_expr(adbin, adrelid)将其转换为SQL表达式 |
      +---------+--------------+------------------------------------------------------------------------------------+
