openGauss

开源数据库

openGauss社区官网

开源社区

PostgreSQL与MogDB/openGauss之数据类型

高云龙2022-04-11PostgreSQL与MogDB/openGauss之数据类型

PostgreSQL 与 MogDB/openGauss 之数据类型

数据库对比版本如下: postgresql 版本 12.2 opengauss 版本 1.0.1

数字类型

PostgreSQLopenGauss存储尺寸备注
tinyint支持1 字节0 ~ 255
smallint支持支持2 字节-32,768 ~ +32,767
integer支持支持4 字节-2,147,483,648 ~ +2,147,483,647
binary_integer支持integer 别名
bigint支持支持8 字节-9,223,372,036,854,775,808 ~ +9,223,372,036,854,775,807
decimal[(p[,s])]支持支持可变字节最高小数点前 131072 位,以及小数点后 16383 位
numeric[(p[,s])]支持支持可变字节最高小数点前 131072 位,以及小数点后 16383 位
number[(p[,s])]支持numeric 别名
real支持支持4 字节6 位十进制数字精度
float4支持4 字节6 位十进制数字精度
double precision支持支持8 字节15 位十进制数字精度
binary_double支持8 字节double precision 别名
float8支持8 字节15 位十进制数字精度
float[(p )]支持4 字节或 8 字节
dec[(p,[s])]支持最高小数点前 131072 位,以及小数点后 16383 位
integer[(p,[s])]支持最高小数点前 131072 位,以及小数点后 16383 位
smallserial支持支持2 字节1 ~ 32,767
serial支持支持4 字节1 ~ 2,147,483,647
bigserial支持支持8 字节1 ~ 9,223,372,036,854,775,807

字符类型

PostgreSQLopenGauss存储尺寸备注
char(n)支持支持pg 中最大为 1GB,og 中最大为 10MBpg 中 n 指字符数量,og 中 n 指字节数量
nchar(n)支持最大为 10MBn 指字节数量
varchar(n)支持支持pg 中最大为 1GB,og 中最大为 10MBpg 中 n 指字符数量,og 中 n 指字节数量
varchar2(n)支持最大为 10MBvarchar(n)别名
nvarchar2(n)支持最大为 10MBn 指字符数量
text支持支持1GB - 1
clob支持1GB - 1text 别名

时间日期类型

PostgreSQLopenGauss存储尺寸备注
timestamp[(p )][without time zone]支持支持8 字节4713 BC - 294276 AD
timestamp[(p )][with time zone]支持支持8 字节4713 BC - 294276 AD
date支持支持4 字节4713 BC - 5874897 AD (og 实际存储空间大小为 8 字节)
time[(p )][without time zone]支持支持8 字节00:00:00 - 24:00:00
time[(p )][with time zone]支持支持12 字节00:00:00+1459 - 24:00:00-1459
interval[fields][(p )]支持支持16 字节-178000000 年 - 178000000 年
smalldatetime支持8 字节日期和时间,不带时区,精确到分钟,秒位大于等于 30 秒进一位
interval day(1) to second(p )支持16 字节
reltime支持4 字节

json 类型

PostgreSQLopenGauss存储尺寸备注
json支持支持
jsonb支持

货币类型

PostgreSQLopenGauss存储尺寸备注
money支持支持8 字节-92233720368547758.08 到+92233720368547758.07