MySQL与openGauss的数据类型对比

需要注意的是,下面列出来的MySQL数据类型指的是information_schema.COLUMNS中的data_type而非column_type。比如对于 int unsigned的column_type,其data_type实际为 int。对于float(5,2)的column_type,其data_type实际为float。

char(1)类型能够正常插入汉字跟数据库模式有关。当数据库是B模式(加载了dolphin插件),char(1)可成功插入1个汉字;当数据库是A模式时,插入1个汉字会失败。 openGauss B库数据类型参考:https://docs-opengauss.osinfra.cn/zh/docs/latest/docs/ExtensionReference/dolphin-%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B.html

MySQLopenGauss备注
intinteger若column_type包含unsigned或者zerofill属性,则类型映射转化为openGauss侧的uint4
tinyinttinyint若column_type包含unsigned或者zerofill属性,则类型映射转化为openGauss侧的uint1
smallintsmallint若column_type包含unsigned或者zerofill属性,则类型映射转化为openGauss侧的uint2
mediumintintegeropenGauss侧mediumint与integer等价,存储空间为4字节,mysql侧的mediumint存储空间为3字节,因此openGauss对应的数值范围更大;若column_type包含unsigned或者zerofill属性,则类型映射转化为openGauss侧的uint4
bigintbigint若column_type包含unsigned或者zerofill属性,则类型映射转化为openGauss侧的uint8
charcharacter支持迁移最大存储长度(character_maximum_length),默认长度为1
varcharcharacter varying支持迁移最大存储长度(character_maximum_length)
datedate
timetime without time zoneMySQL的time类型对应openGauss的time类型,对应的data_type类型为time without time zone
datetimetimestamp without time zoneMySQL的datetime类型对应openGauss的datetime类型,对应的data_type类型为timestamp without time zone
timestamptimestamp with time zoneMySQL的timestamp类型对应openGauss的timestamp类型,对应的data_type类型为timestamp with time zone
yearyear支持设置宽度,year(w),w表示宽度,year(4)输出'YYYY',year(2)输出'YY'
texttext
tinytexttextopenGauss侧tinytext、mediumtext和longtext均是text的别名,与text等价
mediumtexttextopenGauss侧tinytext、mediumtext和longtext均是text的别名,与text等价
longtexttextopenGauss侧tinytext、mediumtext和longtext均是text的别名,与text等价
blobblob
tinyblobtinyblob
mediumblobmediumblob
longbloblongblob
binarybinary
varbinaryvarbinary
decimalnumeric当mysql侧column_type为decimal, dec, numeric和fixed类型时,data_type均对应decimal类型;这些类型均有type, type(p)和type(p,s)三种格式,若未指定精度(p,s),形如type,则为默认精度type(10,0);若未指定s,形如type(p),则默认s=0,即type(p,0);支持迁移精度numeric_precision和numeric_scale,迁移后的类型为numeric(p,s)。
doublenumeric当mysql侧column_type为double,double precision和real类型时,data_type均对应double类型;这些类型均有type和type(p,s)两种格式;若指定精度(p和s),当s!=0时,类型映射转化为numeric(p,s),当s=0时,类型转化为float(p);若未指定精度,则类型映射转换为number,即无默认(10,0)精度的numeric类型。
floatreal当mysql侧column_type为float类型时,data_type对应float类型;float类型有type, type(p)和type(p,s)三种格式,若指定精度(p和s),当s!=0时,类型映射转化为numeric(p,s),当s=0时,类型转化为float(p);若指定p,类型映射转换为float(p),当p位于[1, 24]时,对应data_type为real,当p位于[25, 53]时,对应data_type为double precision;若未指定p,类型映射为float,对应data_type为real。
bitbit支持迁移最大存储长度(character_maximum_length),默认长度为1
enumenum
setset
jsonjson
geometrypoint若openGauss侧安装有postgis,将迁移成geometry类型
pointpoint若openGauss侧安装有postgis,将迁移成geometry类型
linestringpath若openGauss侧安装有postgis,将迁移成geometry类型
polygonpolygon若openGauss侧安装有postgis,将迁移成geometry类型
multipointbytea若openGauss侧安装有postgis,将迁移成geometry类型
geometrycollectionbytea若openGauss侧安装有postgis,将迁移成geometry类型
multilinestringbytea若openGauss侧安装有postgis,将迁移成geometry类型
multipolygonbytea若openGauss侧安装有postgis,将迁移成geometry类型
意见反馈
    openGauss 2026-04-14 20:12:19
    取消