PostgreSQL Tutorial PostgreSQL Advanced PostgreSQL Database Account Management PostgreSQL References
PostgreSQL Tutorial PostgreSQL Advanced PostgreSQL Database Account Management PostgreSQL References

PostgreSQL - Data Types



A Data Type is an attribute which specifies the type of data that will be stored inside each column when creating a table. The data type is a guideline for PostgreSQL to understand what type of data is expected inside of each column, and it also identifies how PostgreSQL will interact with the stored data.

In PostgreSQL, the data types can be mainly classified into four categories:

  • String Data Types
  • Numeric Data Types
  • Date and time Data Types
  • Other Data Types

String Data Types

Data typeDescription
CHARACTER(size)A fixed-length character string. The size parameter specifies the number of characters to store. Space padded on right to equal size characters. Default value 1.
CHAR(size)Synonym for CHARACTER(size)
CHARACTER VARYING(size)A variable-length character string with limit. The size parameter specifies the number of characters to store. Default value 1.
VARCHAR(size)Synonym for CHARACTER VARYING(size)
TEXTA variable-length character string with unlimited length

Numeric Data Types

Data typeDescription
BIT(size)A fixed-length bit string. The number of bits per value is specified in size. Default is 1
BIT VARYING(size)A variable-length bit string. The number of bits per value is specified in size. Default is 1
VARBIT(size)Synonym for BIT VARYING(size)
SMALLINTSigned two-byte integer. Range is from -32768 to +32767
INTEGERSigned four-byte integer. Range is from -2147483648 to +2147483647
BIGINTSigned eight-byte integer. Range is from -9223372036854775808 to +9223372036854775807
INT2Synonym for SMALLINT
INTSynonym for INTEGER
INT4Synonym for INTEGER
INT8Synonym for BIGINT
NUMERIC(size, d)An exact fixed-point number. The total number of digits is specified in size. The number of digits after the decimal point is specified in the d parameter.
DECIMAL(size, d)Synonym for NUMERIC(size, d)
DOUBLE PRECISION8 bytes variable-precision, inexact 15 decimal digits precision
REAL4 bytes variable-precision, inexact 6 decimal digits precision
SMALLSERIALAuto-incrementing two-byte integer. Range is from 1 to 32767
SERIALAuto-incrementing four-byte integer. Range is from 1 to 2147483647
BIGSERIALAuto-incrementing eight-byte integer. Range is from 1 to 9223372036854775807
SERIAL2Synonym for SMALLSERIAL
SERIAL4Synonym for SERIAL
SERIAL8Synonym for BIGSERIAL
MONEYCurrency amount. Range is from -92233720368547758.08 to +92233720368547758.07
BOOLLogical Boolean (true/false)
BOOLEANEqual to BOOL

Date and Time Data Types

Data typeDescription
DATEA calendar date (year, month, day). Format: 'YYYY-MM-DD'.
TIMESTAMP(fsp)A date and time with no time zone. Format: 'YYYY-MM-DD HH:MM:SS'.
TIMESTAMP(fsp) WITHOUT TIME ZONEA date and time with no time zone. Format: 'YYYY-MM-DD HH:MM:SS'.
TIMESTAMP(fsp) WITH TIME ZONE A date and time with no time zone. Format: 'YYYY-MM-DD HH:MM:SS-TZ'.
Equivalent to TIMESTAMPTZ.
TIME(fsp)A time of day with no time zone. Format: 'HH:MM:SS'.
TIME(fsp) WITHOUT TIME ZONEA time of day with no time zone. Format: 'HH:MM:SS'.
TIME(fsp) WITH TIME ZONEA time of day with time zone. Format: 'HH:MM:SS-TZ'.
Equivalent to TIMETZ.
INTERVAL [FIELDS] (fsp)Time span

Other Data Types

Data typeDescription
pg_lsnPostgreSQL Log Sequence Number
byteabinary data (“byte array”)
boxrectangular box on a plane
cidrIPv4 or IPv6 network address
circlecircle on a plane
inetIPv4 or IPv6 host address
jsontextual JSON data
jsonbbinary JSON data, decomposed
lineinfinite line on a plane
lsegline segment on a plane
macaddrMAC (Media Access Control) address
macaddr8MAC (Media Access Control) address (EUI-64 format)
path geometric path on a plane
pg_snapshotuser-level transaction ID snapshot
point geometric point on a plane
polygonclosed geometric path on a plane
tsquerytext search query
tsvectortext search document
txid_snapshotuser-level transaction ID snapshot (deprecated; see pg_snapshot)
uuiduniversally unique identifier
xmlXML data