Data Types

Boolean Type
Boolean

Numerical Types
Integer
smallint, int, bigint
Numeric (aka Decimal)
numeric(precision, scale) [Always specify precision and scale.]
Floating Point
real, double precision
Numeric and Floating Points offers -Infinity, Infinity, NaN

Textual Types
Character
char(n)
Character Varying
varchar(n), varchar()
Text

Temporal Types
Date
Time Stamp Without Time Zone
timestamp [Offers -Infinity and Infinity]
Time Stamp With Time Zone
timestamptz [Offers -Infinity and Infinity]
Interval

JSON Type
JSON
JSONB

You can use full type name or abbreviated type name. For instance, both character varying(10) and varchar(10) will work.

All data types may be casted to text.


Integers

smallint-32768 to +32767
integer-2147483648 to +2147483647
bigint-9223372036854775808 to +9223372036854775807

-3 -2 -1 0 1 2 3
THOUSANDS
HUNDREDS
TENS
ONES
TENTH
HUNDREDTH
THOUSANDTH

Rounding


Castability to Numeric (Precision, Scale)

  1. Round to Scale
  2. Result must be WITHIN absolute value of 10 (Precision - Scale)

Range of Real and Double Precision

real4 bytesprecision of 6 decimal digits
double precision8 bytesprecision of 15 decimal digits
2.22222E122.22222 × 1012All digits significant.
2.222222E122.2222222 × 1012One digit dropped.