0% found this document useful (0 votes)
26 views3 pages

PostgreSQL Data Types Cheatsheet - TablePlus

Uploaded by

aguilar_chris
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views3 pages

PostgreSQL Data Types Cheatsheet - TablePlus

Uploaded by

aguilar_chris
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

PostgreSQL data types cheatsheet

June 21, 2018

Supported data types in PostgreSQL:

Number types
Storage
Name Range
Size

smallint 2 bytes -32768 to +32767

integer 4 bytes -2147483648 to +2147483647

bigint 4 bytes -9223372036854775808 to 9223372036854775807

up to 131072 digits before the decimal point; up to 16383 digits after


decimal variable
the decimal point

up to 131072 digits before the decimal point; up to 16383 digits after


numeric variable
the decimal point

real 4 bytes 6 decimal digits precision

double 8 bytes 15 decimal digits precision

Serial Types
Name Storage Size Range

smallserial 2 bytes 1 to 32767

serial 4 bytes 1 to 2147483647

bigserial 8 bytes 1 to 9223372036854775807

Monetary Types
Name Storage Size Range

money 8 bytes -92233720368547758.08 to 92233720368547758.07


Character Types (or Strings)
Name Description

varchar(n) variable-length with limit

char(n) fixed-length, blank padded

text variable unlimited length

Binary Data Types


Name Storage Size Description

bytea 1 to 4 bytes plus size of binary string variable-length binary string

Date / Time Types


Name Size Range Resolution

timestamp without 1 microsecond / 14


8 bytes 4713 BC to 294276 AD
timezone digits

timestamp with 1 microsecond / 14


8 bytes 4713 BC to 294276 AD
timezone digits

date 4 bytes 4713 BC to 5874897 AD 1 day

1 microsecond / 14
time without timezone 8 bytes 00:00:00 to 24:00:00
digits

12 00:00:00+1459 to 24:00:00- 1 microsecond / 14


time with timezone
bytes 1459 digits

12 -178000000 years to 1 microsecond / 14


interval
bytes 178000000 years digits

Boolean Data Types


Name Size

boolean 1 byte
Geometric Types
Name Size Representation Format

point 16 bytes point on a plane (x,y)

lseg 32 bytes finite line segment ((x1, y1), (x2, y2))

box 32 bytes rectangular box ((x1, y1), (x2, y2))

16 + 16n closed path (similar to polygon, n = total ((x1, y1), (x2, y2), …, (xn,
path
bytes points yn))

16 + 16n [(x1, y1), (x2, y2), …, (xn,


path open path, n = total points
bytes yn)]

40 bytes + ((x1, y1), (x2, y2), …, (xn,


polygon polygon
16n yn))

circle 24 bytes circle – center point and radius <(x, y), r>

Network Address Types


Name Storage Size Description

cidr 7 or 19 bytes IPv4 or IPv6 networks

inet 7 or 19 bytes IPv4 or IPv6 hosts or networks

macaddr 6 bytes MAC addresses

Bit Strings
Name Storage Size Description

bit(n) y + ceil(n / 8) bytes stores exactly n 0s and 1s y = 5 or 8

bit varying(n) y + ceil(n / 8) bytes stores up to n 0s and 1s y = 5 or 8

bit varying variable stores unlimited number of 0s and 1s

You might also like