PostgreSQL
Chapter 8. Data Types
Table of Contents
PostgreSQL has a rich set of native data types available to users. Users can add new types to PostgreSQL using the CREATE TYPE command.
Table 8.1 shows all the built-in general-purpose data types. Most of the alternative names listed in the “[.quote]#Aliases”# column are the names used internally by PostgreSQL for historical reasons. In addition, some internally used or deprecated types are available, but are not listed here.
Table 8.1. Data Types
Name | Aliases | Description |
---|---|---|
|
|
signed eight-byte integer |
|
|
autoincrementing eight-byte integer |
|
fixed-length bit string |
|
|
|
variable-length bit string |
|
|
logical Boolean (true/false) |
|
rectangular box on a plane |
|
|
binary data (“[.quote]#byte array”#) |
|
|
|
fixed-length character string |
|
|
variable-length character string |
|
IPv4 or IPv6 network address |
|
|
circle on a plane |
|
|
calendar date (year, month, day) |
|
|
|
double precision floating-point number (8 bytes) |
|
IPv4 or IPv6 host address |
|
|
|
signed four-byte integer |
|
time span |
|
|
textual JSON data |
|
|
binary JSON data, decomposed |
|
|
infinite line on a plane |
|
|
line segment on a plane |
|
|
MAC (Media Access Control) address |
|
|
MAC (Media Access Control) address (EUI-64 format) |
|
|
currency amount |
|
|
|
exact numeric of selectable precision |
|
geometric path on a plane |
|
|
PostgreSQL Log Sequence Number |
|
|
user-level transaction ID snapshot |
|
|
geometric point on a plane |
|
|
closed geometric path on a plane |
|
|
|
single precision floating-point number (4 bytes) |
|
|
signed two-byte integer |
|
|
autoincrementing two-byte integer |
|
|
autoincrementing four-byte integer |
|
variable-length character string |
|
|
time of day (no time zone) |
|
|
|
time of day, including time zone |
|
date and time (no time zone) |
|
|
|
date and time, including time zone |
|
text search query |
|
|
text search document |
|
|
user-level transaction ID snapshot (deprecated; see |
|
|
universally unique identifier |
|
|
XML data |
+
Compatibility
The following types (or spellings thereof) are specified by SQL: bigint
, bit
, bit varying
, boolean
, char
, character varying
, character
, varchar
, date
, double precision
, integer
, interval
, numeric
, decimal
, real
, smallint
, time
(with or without time zone), timestamp
(with or without time zone), xml
.
Each data type has an external representation determined by its input and output functions. Many of the built-in types have obvious external formats. However, several types are either unique to PostgreSQL, such as geometric paths, or have several possible formats, such as the date and time types. Some of the input and output functions are not invertible, i.e., the result of an output function might lose accuracy when compared to the original input.
Prev | Up | Next |
---|---|---|
7.8. |
8.1. Numeric Types |
Submit correction
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.
Copyright © 1996-2024 The PostgreSQL Global Development Group