Data types
This topic lists the data types available in Greengage DB.
Built-in types
Greengage DB provides a variety of built-in data types for storing different values and objects.
Most of these types originate from PostgreSQL and include data types defined by the SQL standard, such as bigint, bit, bit varying, boolean, character varying, varchar, character, char, date, double precision, integer, interval, numeric, decimal, real, smallint, time (with or without time zone), timestamp (with or without time zone), and xml.
For detailed semantics and behavior of standard data types, see the Data types section in the PostgreSQL documentation.
In addition to user-visible data types, Greengage DB defines internal system types, such as oid.
These types are typically used by the system catalogs and are generally not intended for direct application use.
Extension types
Greengage DB extensions can introduce additional data types that are not part of the core system. Such types are typically designed to support specialized functionality that would be impractical or inefficient to implement using standard SQL types.
Examples include:
-
The
citextextension, which adds thecitexttype for case-insensitive character strings. -
The
hstoreextension, which adds thehstoretype for storing sets of key/value pairs.
Custom types
Users can define custom data types using the CREATE TYPE statement.
Custom types allow modeling domain-specific data more precisely, encapsulating validation rules, or representing complex structures that are not covered by built-in types.
Custom types can be implemented as composite types, enumerated types, or fully user-defined base types. Their behavior and storage characteristics depend on the implementation method.
Data types list
-
Aliases are alternative names for data types that are not defined by the SQL standard. Their usage may reduce portability across different database systems.
-
Detailed information about data types is available in the pg_type system catalog table.
Numeric types
The serial, bigserial, and smallserial types are not actual types with their own specific implementation.
Technically, columns of these types store values of corresponding integer types and use sequences that produce the values in serial order.
| Name | Alias | Size | Range | Description |
|---|---|---|---|---|
bigint |
int8 |
8 bytes |
|
Large-range integer |
bigserial |
serial8 |
8 bytes |
|
Large autoincrementing integer |
decimal[(p, s)] |
numeric[(p, s)] |
Variable |
No limit |
Exact numeric value with user-defined precision.
Up to |
double precision |
float8 |
8 bytes |
15 decimal digits precision |
Double-precision floating-point number (inexact) |
integer |
int, int4 |
4 bytes |
|
Standard integer type |
real |
float4 |
4 bytes |
6 decimal digits precision |
Single-precision floating-point number (inexact) |
serial |
serial4 |
4 bytes |
|
Autoincrementing integer |
smallint |
int2 |
2 bytes |
|
Small-range integer |
smallserial |
serial2 |
2 bytes |
|
Small autoincrementing integer |
Boolean
| Name | Alias | Size | Range | Description |
|---|---|---|---|---|
boolean |
bool |
1 byte |
|
Logical boolean value |
Character types
-
The maximum allowed length (
n) for character types is10485760. -
Values of 127 bytes or larger require four bytes of overhead instead of one.
| Name | Alias | Size | Range | Description |
|---|---|---|---|---|
character[(n)] |
char[(n)] |
1 byte + n |
Strings up to |
Fixed-length, blank-padded character string.
Without |
character varying[(n)] |
varchar[(n)] |
1 byte + string size |
Strings up to |
Variable-length character string with length limit.
Without |
text |
— |
1 byte + string size |
Strings of any length |
Variable-length character string |
Binary type
| Name | Size | Range | Description |
|---|---|---|---|
bytea |
1 or 4 bytes + binary string size |
Sequence of octets |
Variable-length binary string (byte array) |
Date and time types
The p variable in type definitions is the optional precision specification.
It defines the number of fractional digits stored in the seconds field.
For example, the value of 3 allows storing values with millisecond precision.
The allowed range for p is 0 to 6 (or 0 to 10 for the time type when it uses floating-point storage).
| Name | Alias | Size | Range | Description |
|---|---|---|---|---|
date |
— |
4 bytes |
|
Calendar date (year, month, day) |
interval[fields][(p)] |
— |
16 bytes |
|
Time interval |
time[(p)][without time zone] |
— |
8 bytes |
|
Time of day |
time[(p)] with time zone |
timetz |
12 bytes |
|
Time of day with time zone |
timestamp[(p)][without time zone] |
— |
8 bytes |
|
Date and time |
timestamp[(p)] with time zone |
timestamptz |
8 bytes |
|
Date and time with time zone |
Monetary type
| Name | Size | Range | Description |
|---|---|---|---|
money |
8 bytes |
|
Currency amount |
Geometric types
Columns of geometric types cannot be used in distribution keys.
| Name | Size | Range | Description |
|---|---|---|---|
box |
32 bytes |
((x1,y1),(x2,y2)) |
Rectangular box on a plane |
circle |
24 bytes |
<(x,y),r> |
Circle in the plane, defined by a center point and a radius |
line |
24 bytes |
{A,B,C} |
Infinite line on a plane |
lseg |
32 bytes |
((x1,y1),(x2,y2)) |
Line segment on a plane |
path |
16 + 16n bytes |
[(x1,y1),…] ((x1,y1),…) |
Geometric path on a plane: open (square brackets) or closed (parentheses) |
point |
16 bytes |
(x,y) |
Geometric point on a plane |
polygon |
40 + 16n bytes |
((x1,y1),…) |
Polygon on a plane (similar to closed geometric path) |
Network address types
| Name | Size | Description |
|---|---|---|
cidr |
7 or 19 bytes |
IPv4 and IPv6 network addresses |
inet |
7 or 19 bytes |
IPv4 and IPv6 host and network addresses |
macaddr |
6 bytes |
MAC address |
Bit string types
| Name | Alias | Size | Range | Description |
|---|---|---|---|---|
bit[(n)] |
— |
|
Fixed-length bit string |
|
bit varying[(n)] |
varbit |
Actual number of bits |
Variable-length bit string |
Text search types
Columns of text search types cannot be used in distribution keys.
| Name | Range | Description |
|---|---|---|
tsquery |
Set of lexemes to search combined with logical operators |
Text search query |
tsvector |
Sorted list of distinct lexemes |
Text search document |
Structured data formats: XML and JSON
| Name | Size | Range | Description |
|---|---|---|---|
json |
1 byte + JSON size |
JSON of any length |
JSON data stored as text |
jsonb |
1 byte + binary string size |
JSON of any length |
Binary JSON data in decomposed format |
xml |
1 byte + XML size |
XML of any length |
XML data |
UUID
| Name | Size | Range | Description |
|---|---|---|---|
uuid |
16 bytes |
Standard UUID format (32 hexadecimal digits) |
Universally unique identifier (RFC 4122) |
Range types
| Name | Range | Description |
|---|---|---|
int4range |
NOTE
|
Range of |
int8range |
Range of |
|
numrange |
Range of |
|
tsrange |
Range of |
|
tstzrange |
Range of |
|
daterange |
Range of |
Other types
| Name | Size | Range | Description |
|---|---|---|---|
pg_lsn |
8 bytes |
PostgreSQL Log Sequence Number |
|
txid_snapshot |
— |
Transaction ID snapshot |