openGauss
开源数据库
openGauss社区官网
开源社区
PostgreSQL与MogDB/openGauss之数据类型
2022-04-11PostgreSQL与MogDB/openGauss之数据类型
PostgreSQL 与 MogDB/openGauss 之数据类型
数据库对比版本如下: postgresql 版本 12.2 opengauss 版本 1.0.1
数字类型
PostgreSQL | openGauss | 存储尺寸 | 备注 | |
---|---|---|---|---|
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 |
字符类型
PostgreSQL | openGauss | 存储尺寸 | 备注 | |
---|---|---|---|---|
char(n) | 支持 | 支持 | pg 中最大为 1GB,og 中最大为 10MB | pg 中 n 指字符数量,og 中 n 指字节数量 |
nchar(n) | 支持 | 最大为 10MB | n 指字节数量 | |
varchar(n) | 支持 | 支持 | pg 中最大为 1GB,og 中最大为 10MB | pg 中 n 指字符数量,og 中 n 指字节数量 |
varchar2(n) | 支持 | 最大为 10MB | varchar(n)别名 | |
nvarchar2(n) | 支持 | 最大为 10MB | n 指字符数量 | |
text | 支持 | 支持 | 1GB - 1 | |
clob | 支持 | 1GB - 1 | text 别名 |
时间日期类型
PostgreSQL | openGauss | 存储尺寸 | 备注 | |
---|---|---|---|---|
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 类型
PostgreSQL | openGauss | 存储尺寸 | 备注 | |
---|---|---|---|---|
json | 支持 | 支持 | ||
jsonb | 支持 |
货币类型
PostgreSQL | openGauss | 存储尺寸 | 备注 | |
---|---|---|---|---|
money | 支持 | 支持 | 8 字节 | -92233720368547758.08 到+92233720368547758.07 |