9 8.1.2. Arbitrary Precision Numbers
10 8.1.3. Floating-Point Types
15 8.4. Binary Data Types
17 8.4.1. bytea Hex Format
18 8.4.2. bytea Escape Format
22 8.5.1. Date/Time Input
23 8.5.2. Date/Time Output
26 8.5.5. Interval Output
31 8.7.1. Declaration of Enumerated Types
34 8.7.4. Implementation Details
46 8.9. Network Address Types
54 8.10. Bit String Types
55 8.11. Text Search Types
63 8.13.1. Creating XML Values
64 8.13.2. Encoding Handling
65 8.13.3. Accessing XML Values
69 8.14.1. JSON Input and Output Syntax
70 8.14.2. Designing JSON Documents
71 8.14.3. jsonb Containment and Existence
72 8.14.4. jsonb Indexing
73 8.14.5. jsonb Subscripting
79 8.15.1. Declaration of Array Types
80 8.15.2. Array Value Input
81 8.15.3. Accessing Arrays
82 8.15.4. Modifying Arrays
83 8.15.5. Searching in Arrays
84 8.15.6. Array Input and Output Syntax
88 8.16.1. Declaration of Composite Types
89 8.16.2. Constructing Composite Values
90 8.16.3. Accessing Composite Types
91 8.16.4. Modifying Composite Types
92 8.16.5. Using Composite Types in Queries
93 8.16.6. Composite Type Input and Output Syntax
97 8.17.1. Built-in Range and Multirange Types
99 8.17.3. Inclusive and Exclusive Bounds
100 8.17.4. Infinite (Unbounded) Ranges
101 8.17.5. Range Input/Output
102 8.17.6. Constructing Ranges and Multiranges
103 8.17.7. Discrete Range Types
104 8.17.8. Defining New Range Types
106 8.17.10. Constraints on Ranges
109 8.19. Object Identifier Types
113 PostgreSQL has a rich set of native data types available to users.
114 Users can add new types to PostgreSQL using the CREATE TYPE command.
116 Table 8.1 shows all the built-in general-purpose data types. Most of
117 the alternative names listed in the “Aliases” column are the names used
118 internally by PostgreSQL for historical reasons. In addition, some
119 internally used or deprecated types are available, but are not listed
122 Table 8.1. Data Types
123 Name Aliases Description
124 bigint int8 signed eight-byte integer
125 bigserial serial8 autoincrementing eight-byte integer
126 bit [ (n) ] fixed-length bit string
127 bit varying [ (n) ] varbit [ (n) ] variable-length bit string
128 boolean bool logical Boolean (true/false)
129 box rectangular box on a plane
130 bytea binary data (“byte array”)
131 character [ (n) ] char [ (n) ] fixed-length character string
132 character varying [ (n) ] varchar [ (n) ] variable-length character
134 cidr IPv4 or IPv6 network address
135 circle circle on a plane
136 date calendar date (year, month, day)
137 double precision float, float8 double precision floating-point number
139 inet IPv4 or IPv6 host address
140 integer int, int4 signed four-byte integer
141 interval [ fields ] [ (p) ] time span
142 json textual JSON data
143 jsonb binary JSON data, decomposed
144 line infinite line on a plane
145 lseg line segment on a plane
146 macaddr MAC (Media Access Control) address
147 macaddr8 MAC (Media Access Control) address (EUI-64 format)
148 money currency amount
149 numeric [ (p, s) ] decimal [ (p, s) ] exact numeric of selectable
151 path geometric path on a plane
152 pg_lsn PostgreSQL Log Sequence Number
153 pg_snapshot user-level transaction ID snapshot
154 point geometric point on a plane
155 polygon closed geometric path on a plane
156 real float4 single precision floating-point number (4 bytes)
157 smallint int2 signed two-byte integer
158 smallserial serial2 autoincrementing two-byte integer
159 serial serial4 autoincrementing four-byte integer
160 text variable-length character string
161 time [ (p) ] [ without time zone ] time of day (no time zone)
162 time [ (p) ] with time zone timetz time of day, including time zone
163 timestamp [ (p) ] [ without time zone ] date and time (no time zone)
164 timestamp [ (p) ] with time zone timestamptz date and time, including
166 tsquery text search query
167 tsvector text search document
168 txid_snapshot user-level transaction ID snapshot (deprecated; see
170 uuid universally unique identifier
175 The following types (or spellings thereof) are specified by SQL:
176 bigint, bit, bit varying, boolean, char, character varying, character,
177 varchar, date, double precision, integer, interval, numeric, decimal,
178 real, smallint, time (with or without time zone), timestamp (with or
179 without time zone), xml.
181 Each data type has an external representation determined by its input
182 and output functions. Many of the built-in types have obvious external
183 formats. However, several types are either unique to PostgreSQL, such
184 as geometric paths, or have several possible formats, such as the date
185 and time types. Some of the input and output functions are not
186 invertible, i.e., the result of an output function might lose accuracy
187 when compared to the original input.