Home Explore Blog CI



postgresql

14th chunk of `doc/src/sgml/catalogs.sgml`
fe61e746200a9ea6340c86f599246b364273281eac2564450000000100000fad
 zone="catalog-pg-attribute">
   <primary>pg_attribute</primary>
  </indexterm>

  <para>
   The catalog <structname>pg_attribute</structname> stores information about
   table columns.  There will be exactly one
   <structname>pg_attribute</structname> row for every column in every
   table in the database.  (There will also be attribute entries for
   indexes, and indeed all objects that have
   <link linkend="catalog-pg-class"><structname>pg_class</structname></link>
   entries.)
  </para>

  <para>
   The term attribute is equivalent to column and is used for
   historical reasons.
  </para>

  <table>
   <title><structname>pg_attribute</structname> Columns</title>
   <tgroup cols="1">
    <thead>
     <row>
      <entry role="catalog_table_entry"><para role="column_definition">
       Column Type
      </para>
      <para>
       Description
      </para></entry>
     </row>
    </thead>

    <tbody>
     <row>
      <entry role="catalog_table_entry"><para role="column_definition">
       <structfield>attrelid</structfield> <type>oid</type>
       (references <link linkend="catalog-pg-class"><structname>pg_class</structname></link>.<structfield>oid</structfield>)
      </para>
      <para>
       The table this column belongs to
      </para></entry>
     </row>

     <row>
      <entry role="catalog_table_entry"><para role="column_definition">
       <structfield>attname</structfield> <type>name</type>
      </para>
      <para>
       The column name
      </para></entry>
     </row>

     <row>
      <entry role="catalog_table_entry"><para role="column_definition">
       <structfield>atttypid</structfield> <type>oid</type>
       (references <link linkend="catalog-pg-type"><structname>pg_type</structname></link>.<structfield>oid</structfield>)
      </para>
      <para>
       The data type of this column (zero for a dropped column)
      </para></entry>
     </row>

     <row>
      <entry role="catalog_table_entry"><para role="column_definition">
       <structfield>attlen</structfield> <type>int2</type>
      </para>
      <para>
       A copy of <literal>pg_type.typlen</literal> of this column's
       type
      </para></entry>
     </row>

     <row>
      <entry role="catalog_table_entry"><para role="column_definition">
       <structfield>attnum</structfield> <type>int2</type>
      </para>
      <para>
       The number of the column.  Ordinary columns are numbered from 1
       up.  System columns, such as <structfield>ctid</structfield>,
       have (arbitrary) negative numbers.
      </para></entry>
     </row>

     <row>
      <entry role="catalog_table_entry"><para role="column_definition">
       <structfield>atttypmod</structfield> <type>int4</type>
      </para>
      <para>
       <structfield>atttypmod</structfield> records type-specific data
       supplied at table creation time (for example, the maximum
       length of a <type>varchar</type> column).  It is passed to
       type-specific input functions and length coercion functions.
       The value will generally be -1 for types that do not need <structfield>atttypmod</structfield>.
      </para></entry>
     </row>

     <row>
      <entry role="catalog_table_entry"><para role="column_definition">
       <structfield>attndims</structfield> <type>int2</type>
      </para>
      <para>
       Number of dimensions, if the column is an array type; otherwise 0.
       (Presently, the number of dimensions of an array is not enforced,
       so any nonzero value effectively means <quote>it's an array</quote>.)
      </para></entry>
     </row>

     <row>
      <entry role="catalog_table_entry"><para role="column_definition">
       <structfield>attbyval</structfield> <type>bool</type>
      </para>
      <para>
       A copy of <literal>pg_type.typbyval</literal> of this column's type
      </para></entry>
     </row>

     <row>
      <entry role="catalog_table_entry"><para role="column_definition">
       <structfield>attalign</structfield> <type>char</type>

Title: pg_attribute Columns
Summary
This section details the columns of the pg_attribute catalog, which stores information about table columns. It lists and describes columns such as attrelid (the table the column belongs to), attname (the column name), atttypid (the data type of the column), attlen (a copy of pg_type.typlen), attnum (the column number), atttypmod (type-specific data), attndims (number of dimensions for array types), attbyval (a copy of pg_type.typbyval).