<!-- doc/src/sgml/datatype.sgml -->
<chapter id="datatype">
<title>Data Types</title>
<indexterm zone="datatype">
<primary>data type</primary>
</indexterm>
<indexterm>
<primary>type</primary>
<see>data type</see>
</indexterm>
<para>
<productname>PostgreSQL</productname> has a rich set of native data
types available to users. Users can add new types to
<productname>PostgreSQL</productname> using the <xref
linkend="sql-createtype"/> command.
</para>
<para>
<xref linkend="datatype-table"/> shows all the built-in general-purpose data
types. Most of the alternative names listed in the
<quote>Aliases</quote> column are the names used internally by
<productname>PostgreSQL</productname> for historical reasons. In
addition, some internally used or deprecated types are available,
but are not listed here.
</para>
<table id="datatype-table">
<title>Data Types</title>
<tgroup cols="3">
<colspec colname="col1" colwidth="2*"/>
<colspec colname="col2" colwidth="1*"/>
<colspec colname="col3" colwidth="2*"/>
<thead>
<row>
<entry>Name</entry>
<entry>Aliases</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry><type>bigint</type></entry>
<entry><type>int8</type></entry>
<entry>signed eight-byte integer</entry>
</row>
<row>
<entry><type>bigserial</type></entry>
<entry><type>serial8</type></entry>
<entry>autoincrementing eight-byte integer</entry>
</row>
<row>
<entry><type>bit [ (<replaceable>n</replaceable>) ]</type></entry>
<entry></entry>
<entry>fixed-length bit string</entry>
</row>
<row>
<entry><type>bit varying [ (<replaceable>n</replaceable>) ]</type></entry>
<entry><type>varbit [ (<replaceable>n</replaceable>) ]</type></entry>
<entry>variable-length bit string</entry>
</row>
<row>
<entry><type>boolean</type></entry>
<entry><type>bool</type></entry>
<entry>logical Boolean (true/false)</entry>
</row>
<row>
<entry><type>box</type></entry>
<entry></entry>
<entry>rectangular box on a plane</entry>
</row>
<row>
<entry><type>bytea</type></entry>
<entry></entry>
<entry>binary data (<quote>byte array</quote>)</entry>
</row>
<row>
<entry><type>character [ (<replaceable>n</replaceable>) ]</type></entry>
<entry><type>char [ (<replaceable>n</replaceable>) ]</type></entry>
<entry>fixed-length character string</entry>
</row>
<row>
<entry><type>character varying [ (<replaceable>n</replaceable>) ]</type></entry>
<entry><type>varchar [ (<replaceable>n</replaceable>) ]</type></entry>
<entry>variable-length character string</entry>
</row>
<row>
<entry><type>cidr</type></entry>
<entry></entry>
<entry>IPv4 or IPv6 network address</entry>
</row>
<row>
<entry><type>circle</type></entry>
<entry></entry>
<entry>circle on a plane</entry>
</row>
<row>
<entry><type>date</type></entry>
<entry></entry>
<entry>calendar date (year, month, day)</entry>
</row>
<row>
<entry><type>double precision</type></entry>
<entry><type>float8</type></entry>
<entry>double precision floating-point number (8 bytes)</entry>
</row>
<row>
<entry><type>inet</type></entry>
<entry></entry>
<entry>IPv4 or IPv6 host address</entry>
</row>
<row>
<entry><type>integer</type></entry>
<entry><type>int</type>, <type>int4</type></entry>
<entry>signed four-byte integer</entry>
</row>
<row>
<entry><type>interval [ <replaceable>fields</replaceable> ] [ (<replaceable>p</replaceable>) ]</type></entry>
<entry></entry>
<entry>time