Database Reference
In-Depth Information
PostgreSQL's supported data types
PostgreSQL is very vast when it comes to supporting different data types. Apart
from existing data types, a user can add new data types in PostgreSQL. In order to
add new data types, a user can use the
CREATE TYPE
command. The following list
shows a number of built-in data types that are supported by PostgreSQL.
Let's go through all the supported data types one by one:
•
bigint
: This is a signed 8-byte integer, and it is represented as
int8
.
•
bigserial
: This is an auto incrementing 8-byte integer represented by
the
serial8
keyword.
•
bit[(n)]
: This is a ixed length bit string and is represented by the
bit
keyword.
•
bit varying [(n)]
: This is a variable length bit string and is represented
by the
varbit
keyword.
•
boolean
: This is a logical Boolean expression and has the
true
or
false
value. It is represented by the
bool
keyword.
•
box
: This is a rectangular box on a plane and is represented by the
box
keyword.
•
bytea
: This is binary data stored in the form of a byte array and is
represented by the
bytea
keyword.
•
character [(n)]
: This is a ixed length character string, and it is
represented by the
char[(n)]
keyword, where
n
represents the length
of the string.
•
character varying[(n)]
: This is a variable length character string, which is
represented by the
varchar[(n)]
keyword.
•
cidr
: This is used to store the IPv4 and IPv6 network addresses.
It is represented by the
cidr
keyword.
•
circle
: This is a circle on a plane, and it is represented by the
circle
keyword.
•
date
: This is a calendar date, which includes the year, month, and day.
•
double Precision
: This is a loating-point number of 8 bytes. It is
represented by the
float8
keyword.
•
inet
: This is used to store the IPv4 or IPv6 host addresses. The essential
difference between the
inet
and
cidr
data types is that
inet
accepts values
with nonzero bits to the right of the net mask, whereas
cidr
does not.
•
integer
: This is a signed 4-byte integer. It is represented by the
int
and
int4
keywords.