The content of this page has been automatically translated by AI. If you encounter any problems while reading, you can view the corresponding content in Chinese.

Data Type

Last updated: 2024-08-22 16:56:42

Numeric Types

Name
Storage Size
Description
Scope
smallint
2 bytes
Small range of integers
-32768 to +32767
integer
4 bytes
Typical choice for integers
-2147483648 to +2147483647
bigint
8 bytes
Large range of integers
-9223372036854775808 to +9223372036854775807
decimal
Variable
User-specified precision, exact
Up to 131072 digits before the decimal point and 16383 digits after the decimal point
numeric
Variable
User-specified precision, exact
Up to 131072 digits before the decimal point and 16383 digits after the decimal point
real
4 bytes
Variable precision, inexact
6-digit decimal precision
double precision
8 bytes
Variable precision, inexact
15-digit decimal precision
smallserial
2 bytes
Auto-incrementing small integer
1–32767
serial
4 bytes
Auto-incrementing integer
1–2147483647
bigserial
8 bytes
Auto-incrementing large integer
1–9223372036854775807

Character type

Name
Description
character varying(n), varchar(n)
Restricted variable length
character(n), char(n)
Fixed length, space-padded
text
1G

Binary data type

Name
Storage Size
Description
bytea
1 or 4 bytes plus actual binary string
Variable length binary string

Date Type

Name
Storage Size
Description
Minimum value
Maximum value
Resolution
timestamp [ (p) ] [ without time zone ]
8 bytes
Includes Date and Time (no Timezone)
4713 BC
294276 AD
1 microsecond / 14 bits
timestamp [ (p) ] with time zone
8 bytes
Includes Date and Time, with Timezone
4713 BC
294276 AD
1 microsecond / 14 bits
date
4 bytes
Date (without Time of Day)
4713 BC
5874897 AD
1 day
time [ (p) ] [ without time zone ]
8 bytes
Time of Day (no Date)
0:00:00
24:00:00
1 microsecond / 14 bits
time [ (p) ] with time zone
12 bytes
Time of Day only, with Timezone
00:00:00+1459
24:00:00-1459
1 microsecond / 14 bits
interval [ fields ] [ (p) ]
16 bytes
Time Interval
-178,000,000 years
178,000,000 years
1 microsecond / 14 bits

Boolean

Name
Storage Bytes
Description
boolean
1 byte
Status is true or false

For more data type introductions

Please click the link https://www.postgresql.org/docs/10/static/datatype.html to view more data type descriptions