PostgreSQL

PostgreSQL 数据类型

分类 名称 存储空间 范围 描述
数值类型 int2/smallint 2 bytes -32768 到 +32767 small-range integer
数值类型 int4/integer 4 bytes -2147483648 到 +2147483647 typical choice for integer
数值类型 int8/bigint 8 bytes -9223372036854775808 到 +9223372036854775807 large-range integer
数值类型 decimal/NUMERIC 变长 无限制 decimal(6,5) 数字长度为6,一位整数,5位小数,最后四舍五入
数值类型 float4/REAL 4 bytes 7位小数,第七位是四舍五入上来的
数值类型 float8/DOUBLE PRECISION 8 bytes 16位小数,第16位以后舍去?
数值类型 serial2/SMALLSERIAL NOT NULL 2 bytes 1 到 32767 小自增整数
数值类型 serial4/SERIAL NOT NULL 4 bytes 1 到 2147483647
数值类型 serial8/BIGSERIAL NOT NULL 8 bytes 1 到 9223372036854775807
货币类型 money 8 bytes 不会进行四舍五入
字符类型 varchar(n) CHARACTER VARYING(64) 限制长度
CHARACTER VARYING 不限量
字符类型 char(n) 一般不用,与varchar有区别
字符类型 text
时间类型 timestamp/TIMESTAMP(6) WITHOUT TIME ZONE 8 bytes

参考文档

原文地址:https://www.cnblogs.com/duchaoqun/p/13024107.html