Data types in Postgres
| Data type |
Length |
Description |
| bigint |
8 |
Integer from -2^63 (-9 223 372 036 854 775 808) to 2^63-1 (9 223 372 036 854 775 807) |
| integer |
4 |
Integer from -2^31 (-2 147 483 648) to 2^31-1 (2 147 483 647) |
| smallint |
2 |
Integer from -2^15 (-32 768) to 2^15-1 (32 767) |
| tinyint |
1 |
Integer from 0 to 255 |
| bit |
1 bit |
Integer 0 or 1. |
| boolean |
1 |
Integer 0 or 1 or unknown (null) |
| decimal(precision, scale) |
n |
Numeric data type with fixed precision and scale (up to 131072 digits before the decimal point and up to 16383 digits after the decimal point). |
| numeric(precision, scale) |
n |
The same as decimal data type. |
| real |
4 |
Numeric data type with float precision to 6 decimal positions. |
| double precision |
8 |
Numeric data type with float precision to 15 decimal positions. |
| money |
8 |
Financial data type from -92233720368547758.08 to +92233720368547758.07. |
| timestamp (precision) |
8 |
Date and time without time zone, where the precision can be entered as 0 (whole seconds) to 6 (microseconds). |
| timestamptz (precision) |
8 |
Date and time with time zone, where the precision can be entered as 0 (whole seconds) to 6 (microseconds). |
| char(n) |
n |
Text string of fixed length (maximum length: 8000 characters) |
| varchar(n) |
n |
Text string of variable length (maximum length: 8000 characters) |
| text |
unlimited |
Text string of variable length (maximum length: 2^31-1 = 2 147 483 647 characters) |
See
https://www.postgresql.org/docs/11/datatype.html.