<HTML ><HEAD ><TITLE >pg_attribute</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.73 "><LINK REV="MADE" HREF="mailto:pgsql-docs@postgresql.org"><LINK REL="HOME" TITLE="PostgreSQL 7.3.2 Documentation" HREF="index.html"><LINK REL="UP" TITLE="System Catalogs" HREF="catalogs.html"><LINK REL="PREVIOUS" TITLE="pg_attrdef" HREF="catalog-pg-attrdef.html"><LINK REL="NEXT" TITLE="pg_cast" HREF="catalog-pg-cast.html"><LINK REL="STYLESHEET" TYPE="text/css" HREF="stylesheet.css"><META NAME="creation" CONTENT="2003-02-03T20:17:34"></HEAD ><BODY CLASS="SECT1" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >PostgreSQL 7.3.2 Documentation</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="catalog-pg-attrdef.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" >Chapter 3. System Catalogs</TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="catalog-pg-cast.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="SECT1" ><H1 CLASS="SECT1" ><A NAME="CATALOG-PG-ATTRIBUTE" >3.7. pg_attribute</A ></H1 ><P > <TT CLASS="STRUCTNAME" >pg_attribute</TT > stores information about table columns. There will be exactly one <TT CLASS="STRUCTNAME" >pg_attribute</TT > row for every column in every table in the database. (There will also be attribute entries for indexes and other objects. See <TT CLASS="STRUCTNAME" >pg_class</TT >.) </P ><P > The term attribute is equivalent to column and is used for historical reasons. </P ><DIV CLASS="TABLE" ><A NAME="AEN52696" ></A ><P ><B >Table 3-7. pg_attribute Columns</B ></P ><TABLE BORDER="1" CLASS="CALSTABLE" ><THEAD ><TR ><TH ALIGN="LEFT" VALIGN="TOP" >Name</TH ><TH ALIGN="LEFT" VALIGN="TOP" >Type</TH ><TH ALIGN="LEFT" VALIGN="TOP" >References</TH ><TH ALIGN="LEFT" VALIGN="TOP" >Description</TH ></TR ></THEAD ><TBODY ><TR ><TD ALIGN="LEFT" VALIGN="TOP" >attrelid</TD ><TD ALIGN="LEFT" VALIGN="TOP" ><TT CLASS="TYPE" >oid</TT ></TD ><TD ALIGN="LEFT" VALIGN="TOP" >pg_class.oid</TD ><TD ALIGN="LEFT" VALIGN="TOP" >The table this column belongs to</TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="TOP" >attname</TD ><TD ALIGN="LEFT" VALIGN="TOP" ><TT CLASS="TYPE" >name</TT ></TD ><TD ALIGN="LEFT" VALIGN="TOP" > </TD ><TD ALIGN="LEFT" VALIGN="TOP" >Column name</TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="TOP" >atttypid</TD ><TD ALIGN="LEFT" VALIGN="TOP" ><TT CLASS="TYPE" >oid</TT ></TD ><TD ALIGN="LEFT" VALIGN="TOP" >pg_type.oid</TD ><TD ALIGN="LEFT" VALIGN="TOP" >The data type of this column</TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="TOP" >attstattarget</TD ><TD ALIGN="LEFT" VALIGN="TOP" ><TT CLASS="TYPE" >int4</TT ></TD ><TD ALIGN="LEFT" VALIGN="TOP" > </TD ><TD ALIGN="LEFT" VALIGN="TOP" > <TT CLASS="STRUCTFIELD" >attstattarget</TT > controls the level of detail of statistics accumulated for this column by <TT CLASS="COMMAND" >ANALYZE</TT >. A zero value indicates that no statistics should be collected. A negative value says to use the system default statistics target. The exact meaning of positive values is datatype-dependent. For scalar datatypes, <TT CLASS="STRUCTFIELD" >attstattarget</TT > is both the target number of <SPAN CLASS="QUOTE" >"most common values"</SPAN > to collect, and the target number of histogram bins to create. </TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="TOP" >attlen</TD ><TD ALIGN="LEFT" VALIGN="TOP" ><TT CLASS="TYPE" >int2</TT ></TD ><TD ALIGN="LEFT" VALIGN="TOP" > </TD ><TD ALIGN="LEFT" VALIGN="TOP" > This is a copy of <TT CLASS="STRUCTNAME" >pg_type</TT >.<TT CLASS="STRUCTFIELD" >typlen</TT > of this column's type. </TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="TOP" >attnum</TD ><TD ALIGN="LEFT" VALIGN="TOP" ><TT CLASS="TYPE" >int2</TT ></TD ><TD ALIGN="LEFT" VALIGN="TOP" > </TD ><TD ALIGN="LEFT" VALIGN="TOP" > The number of the column. Ordinary columns are numbered from 1 up. System columns, such as <TT CLASS="STRUCTFIELD" >oid</TT >, have (arbitrary) negative numbers. </TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="TOP" >attndims</TD ><TD ALIGN="LEFT" VALIGN="TOP" ><TT CLASS="TYPE" >int4</TT ></TD ><TD ALIGN="LEFT" VALIGN="TOP" > </TD ><TD ALIGN="LEFT" VALIGN="TOP" > 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 <SPAN CLASS="QUOTE" >"it's an array"</SPAN >.) </TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="TOP" >attcacheoff</TD ><TD ALIGN="LEFT" VALIGN="TOP" ><TT CLASS="TYPE" >int4</TT ></TD ><TD ALIGN="LEFT" VALIGN="TOP" > </TD ><TD ALIGN="LEFT" VALIGN="TOP" > Always -1 in storage, but when loaded into a tuple descriptor in memory this may be updated to cache the offset of the attribute within the tuple. </TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="TOP" >atttypmod</TD ><TD ALIGN="LEFT" VALIGN="TOP" ><TT CLASS="TYPE" >int4</TT ></TD ><TD ALIGN="LEFT" VALIGN="TOP" > </TD ><TD ALIGN="LEFT" VALIGN="TOP" > <TT CLASS="STRUCTFIELD" >atttypmod</TT > records type-specific data supplied at table creation time (for example, the maximum length of a <TT CLASS="TYPE" >varchar</TT > 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 typmod. </TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="TOP" >attbyval</TD ><TD ALIGN="LEFT" VALIGN="TOP" ><TT CLASS="TYPE" >bool</TT ></TD ><TD ALIGN="LEFT" VALIGN="TOP" > </TD ><TD ALIGN="LEFT" VALIGN="TOP" > A copy of <TT CLASS="STRUCTNAME" >pg_type</TT >.<TT CLASS="STRUCTFIELD" >typbyval</TT > of this column's type </TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="TOP" >attstorage</TD ><TD ALIGN="LEFT" VALIGN="TOP" ><TT CLASS="TYPE" >char</TT ></TD ><TD ALIGN="LEFT" VALIGN="TOP" > </TD ><TD ALIGN="LEFT" VALIGN="TOP" > Normally a copy of <TT CLASS="STRUCTNAME" >pg_type</TT >.<TT CLASS="STRUCTFIELD" >typstorage</TT > of this column's type. For TOASTable datatypes, this can be altered after column creation to control storage policy. </TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="TOP" >attisset</TD ><TD ALIGN="LEFT" VALIGN="TOP" ><TT CLASS="TYPE" >bool</TT ></TD ><TD ALIGN="LEFT" VALIGN="TOP" > </TD ><TD ALIGN="LEFT" VALIGN="TOP" > If true, this attribute is a set. In that case, what is really stored in the attribute is the OID of a tuple in the <TT CLASS="STRUCTNAME" >pg_proc</TT > catalog. The <TT CLASS="STRUCTNAME" >pg_proc</TT > tuple contains the query string that defines this set - i.e., the query to run to get the set. So the <TT CLASS="STRUCTFIELD" >atttypid</TT > (see above) refers to the type returned by this query, but the actual length of this attribute is the length (size) of an <TT CLASS="TYPE" >oid</TT >. --- At least this is the theory. All this is probably quite broken these days. </TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="TOP" >attalign</TD ><TD ALIGN="LEFT" VALIGN="TOP" ><TT CLASS="TYPE" >char</TT ></TD ><TD ALIGN="LEFT" VALIGN="TOP" > </TD ><TD ALIGN="LEFT" VALIGN="TOP" > A copy of <TT CLASS="STRUCTNAME" >pg_type</TT >.<TT CLASS="STRUCTFIELD" >typalign</TT > of this column's type </TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="TOP" >attnotnull</TD ><TD ALIGN="LEFT" VALIGN="TOP" ><TT CLASS="TYPE" >bool</TT ></TD ><TD ALIGN="LEFT" VALIGN="TOP" > </TD ><TD ALIGN="LEFT" VALIGN="TOP" > This represents a NOT NULL constraint. It is possible to change this field to enable or disable the constraint. </TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="TOP" >atthasdef</TD ><TD ALIGN="LEFT" VALIGN="TOP" ><TT CLASS="TYPE" >bool</TT ></TD ><TD ALIGN="LEFT" VALIGN="TOP" > </TD ><TD ALIGN="LEFT" VALIGN="TOP" > This column has a default value, in which case there will be a corresponding entry in the <TT CLASS="STRUCTNAME" >pg_attrdef</TT > catalog that actually defines the value. </TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="TOP" >attisdropped</TD ><TD ALIGN="LEFT" VALIGN="TOP" ><TT CLASS="TYPE" >bool</TT ></TD ><TD ALIGN="LEFT" VALIGN="TOP" > </TD ><TD ALIGN="LEFT" VALIGN="TOP" > This column has been dropped and is no longer valid. A dropped column is still physically present in the table, but is ignored by the parser and so cannot be accessed via SQL. </TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="TOP" >attislocal</TD ><TD ALIGN="LEFT" VALIGN="TOP" ><TT CLASS="TYPE" >bool</TT ></TD ><TD ALIGN="LEFT" VALIGN="TOP" > </TD ><TD ALIGN="LEFT" VALIGN="TOP" > This column is defined locally in the relation. Note that a column may be locally defined and inherited simultaneously. </TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="TOP" >attinhcount</TD ><TD ALIGN="LEFT" VALIGN="TOP" ><TT CLASS="TYPE" >int4</TT ></TD ><TD ALIGN="LEFT" VALIGN="TOP" > </TD ><TD ALIGN="LEFT" VALIGN="TOP" > The number of direct ancestors this column has. A column with a nonzero number of ancestors cannot be dropped nor renamed. </TD ></TR ></TBODY ></TABLE ></DIV ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="catalog-pg-attrdef.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="catalog-pg-cast.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >pg_attrdef</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="catalogs.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >pg_cast</TD ></TR ></TABLE ></DIV ></BODY ></HTML >