Tutorialsteacher

Follow Us

PostgreSQL Data Types

In PostgreSQL, a data type is a classification of data based on the type of value it represents. The data type of a column in a PostgreSQL table determines the type of data that can be stored in that column, as well as the operations that can be performed on the data.

PostgreSQL provides a wide variety of data types that can be used to store different kinds of data, such as numbers, text, dates, and more complex data structures like arrays, geometric shapes, and network addresses.

Data TypeDescriptionRange of Values
bigint8-byte integer-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
bigserialAutoincrementing 8-byte integer1 to 9,223,372,036,854,775,807
bitFixed-length bit stringn/a
bit varyingVariable-length bit string0 to 2^(n)-1 bits, where n is the length of the string
booleanLogical Boolean (true/false) valuetrue or false
boxRectangular box (defined by two points: bottom-left and top-right)N/A
byteaBinary data ("byte array")0 to 1 GB
characterFixed-length character string (deprecated; use "char" or "character(n)" instead)N/A
character(n)Fixed-length character string of length nN/A
charFixed-length character stringN/A
cidrIPv4 or IPv6 network addressIPv4: x.x.x.x/y where x is a number between 0 and 255 and y is a number between 0 and 32, IPv6: x:x:x:x:x:x:x:x/y where x is a hexadecimal number between 0 and FFFF and y is a number between 0 and 128
circleCircle (defined by a center point and a radius)N/A
dateCalendar date (year, month, and day)4713 BC to 5874897 AD
double precisionDouble-precision floating-point number (8 bytes)Approximately 15 decimal digits
inetIPv4 or IPv6 host addressIPv4: x.x.x.x where x is a number between 0 and 255, IPv6: x:x:x:x:x:x:x:x where x is a hexadecimal number between 0 and FFFF
integer4-byte integer-2,147,483,648 to 2,147,483,647
intervalTime interval-178000000 years to 178000000 years
jsonJSON data1 byte to 1 GB
jsonbBinary JSON dataN/A
lineInfinite line (defined by two points)N/A
lsegLine segment (defined by two points)N/A
macaddrMAC (Media Access Control) address00:00:00:00:00:00 to FF:FF:FF:FF:FF:FF
moneyCurrency amount-92233720368547758.08 to +92233720368547758.07
numericArbitrary-precision decimal number-10^131071 to 10^131071
pathGeometric path (defined by points connected by straight lines or circular arcs)N/A
pointPoint in a two-dimensional planeN/A
polygonClosed geometric shape (defined by a set of connected points)N/A
realSingle-precision floating-point number (4 bytes)-3.402823e38 to 3.402823e38
smallint2-byte integer-32768 to 32767
smallserialAutoincrementing 2-byte integer1 to 32767
serialAutoincrementing 4-byte integer1 to 2147483647
textVariable-length character stringNo specified limit
timeTime of day (no date)00:00:00 to 24:00:00.
time with time zoneTime of day with time zoneN/A
timestampDate and time (no time zone)4713 BC to 294276 AD
timestamp with time zoneDate and time with time zoneN/A
tsqueryText search queryN/A
tsvectorText search documentN/A
txid_snapshotTransaction ID snapshotN/A
uuidUniversally unique identifierN/A
xmlXML dataN/A