数据仓库服务 GaussDB(DWS)-集合类型:类型对照

时间:2025-02-12 15:05:07

类型对照

表1 集合类型对照表

MySQL集合类型

MySQL INPUT

GaussDB (DWS) OUTPUT

ENUM

ENUM

VARCHAR

SET

SET

VARCHAR

  • 对于ENUM的类型转换,将转换为VARCHAR类型,精度大小为枚举值中最长字段长度的4倍,并使用CHECK()函数确保输入枚举值的正确性
  • 对于SET的类型转换,将转换为VARCHAR类型,精度大小为各枚举值字段长度与分隔符数量和的4倍。

输入示例ENUM

1234
CREATE TABLE IF NOT EXISTS `runoob_dataType_test`(     id   int(2) PRIMARY KEY,    `dataType_17` ENUM('dws-1', 'dws-2', 'dws-3'));

输出示例

12345678
CREATE TABLE IF NOT EXISTS "public"."runoob_datatype_test"(  "id" INTEGER(2) PRIMARY KEY,  "datatype_17" VARCHAR(20) CHECK (dataType_17 IN('dws-1','dws-2','dws-3','', null)))  WITH ( ORIENTATION = ROW, COMPRESSION = NO )  NOCOMPRESS  DISTRIBUTE BY HASH ("id");

输入示例SET

123
CREATE TABLE IF NOT EXISTS `runoob_tbl_test`(    `dataType_18` SET('dws-1', 'dws-2', 'dws-3'));

输出示例

1234567
CREATE TABLE IF NOT EXISTS "public"."runoob_tbl_test"(  "datatype_18" VARCHAR(68))  WITH ( ORIENTATION = ROW, COMPRESSION = NO )  NOCOMPRESS  DISTRIBUTE BY HASH ("datatype_18");
support.huaweicloud.com/tg-dws/dws_16_0113.html