华为云用户手册

  • RENAME 重命名表名 MySQL重命名表名的语句与 GaussDB (DWS)有一些差异。DSC工具迁移时会根据GaussDB(DWS)的特性进行相应适配。 工具暂不支持原表名附有DATABASE(SCHEMA)的场景。 MySQL通过RENAME TABLE语句修改表名。 输入示例 1 2 3 4 5 # 单表重命名 RENAME TABLE DEPARTMENT TO NEWDEPT; # 多表重命名 RENAME TABLE NEWDEPT TO NEWDEPT_02,PEOPLE TO PEOPLE_02; 输出示例 1 2 3 4 5 6 --单表重命名 ALTER TABLE "public"."department" RENAME TO "newdept"; --多表重命名 ALTER TABLE "public"."newdept" RENAME TO "newdept_02"; ALTER TABLE "public"."people" RENAME TO "people_02"; MySQL通过ALTER TABLE RENAME 语句修改表名,DSC工具迁移该语句时会将“AS”关键字迁移为“TO”。 输入示例 1 2 3 4 5 ## A. ALTER TABLE runoob_alter_test RENAME TO runoob_alter_testnew; ## B. ALTER TABLE runoob_alter_testnew RENAME AS runoob_alter_testnewnew; 输出示例 1 2 3 4 5 -- A. ALTER TABLE "public"."runoob_alter_test" RENAME TO "runoob_alter_testnew"; -- B. ALTER TABLE "public"."runoob_alter_testnew" RENAME TO "runoob_alter_testnewnew"; 父主题: 表(可选参数、操作)
  • ROUNDROBIN表 GaussDB(DWS)支持建立roundrobin表,根据实际需要设置表1中的参数table.type进行配置。设置table.type=ROUND-ROBIN。 输入示例 1 2 3 4 5 CREATE TABLE charge_snapshot ( id bigint NOT NULL, profit_model integer, ladder_rebate_rule text ); 输出示例 1 2 3 4 5 CREATE TABLE "public"."charge_snapshot" ( "id" BIGINT NOT NULL, "profit_model" INTEGER, "ladder_rebate_rule" TEXT ) WITH (ORIENTATION = ROW, COMPRESSION = NO) NOCOMPRESS DISTRIBUTE BY ROUNDROBIN; 父主题: 表(可选参数、操作)
  • MODIFY修改列 MySQL使用MODIFY关键字修改列数据类型、设置非空约束。DSC工具迁移时会根据GaussDB(DWS)的特性进行相应适配。 输入示例 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 CREATE TABLE IF NOT EXISTS `runoob_alter_test`( `dataType0` varchar(100), `dataType1` bigint, `dataType2` bigint, `dataType3` bigint )ENGINE=InnoDB DEFAULT CHARSET=utf8; ## A. ALTER TABLE runoob_alter_test MODIFY dataType1 smallint; ## B. ALTER TABLE runoob_alter_test MODIFY dataType1 smallint NOT NULL; ## C. ALTER TABLE runoob_alter_test MODIFY dataType1 smallint NOT NULL FIRST; ## D. ALTER TABLE runoob_alter_test MODIFY dataType1 smallint NOT NULL AFTER dataType3; 输出示例 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 CREATE TABLE "public"."runoob_alter_test" ( "datatype0" VARCHAR(400), "datatype1" BIGINT, "datatype2" BIGINT, "datatype3" BIGINT ) WITH ( ORIENTATION = ROW, COMPRESSION = NO ) NOCOMPRESS DISTRIBUTE BY HASH ("datatype0"); -- A. ALTER TABLE "public"."runoob_alter_test" MODIFY "datatype1" SMALLINT NULL DEFAULT NULL; -- B. ALTER TABLE "public"."runoob_alter_test" MODIFY "datatype1" SMALLINT NOT NULL; -- C. ALTER TABLE "public"."runoob_alter_test" MODIFY "datatype1" SMALLINT NOT NULL; -- D. ALTER TABLE "public"."runoob_alter_test" MODIFY "datatype1" SMALLINT NOT NULL; 父主题: 表(可选参数、操作)
  • LIKE 表克隆 MySQL数据库中,可以使用CREATE TABLE .. LIKE ..方式克隆旧表结构创建新表。GaussDB(DWS)也支持这种建表方式。DSC工具迁移时会添加额外的表属性信息。 输入示例 1 2 3 4 5 6 7 8 CREATE TABLE IF NOT EXISTS `public`.`runoob_tbl_old`( `dataType_1` YEAR, `dataType_2` YEAR(4), `dataType_3` YEAR DEFAULT '2018', `dataType_4` TIME DEFAULT NULL ); CREATE TABLE `runoob_tbl` (like `runoob_tbl_old`); 输出示例 1 2 3 4 5 6 7 8 9 10 11 12 13 CREATE TABLE IF NOT EXISTS "public"."runoob_tbl_old" ( "datatype_1" SMALLINT, "datatype_2" SMALLINT, "datatype_3" SMALLINT DEFAULT '2018', "datatype_4" TIME WITHOUT TIME ZONE DEFAULT NULL ) WITH ( ORIENTATION = ROW, COMPRESSION = NO ) NOCOMPRESS DISTRIBUTE BY HASH ("datatype_1"); CREATE TABLE "public"."runoob_tbl"( LIKE "public"."runoob_tbl_old" INCLUDING COMMENTS INCLUDING CONSTRAINTS INCLUDING DEFAULTS INCLUDING INDEXES INCLUDING STORAGE); 父主题: 表(可选参数、操作)
  • DROP删除表 GaussDB(DWS)与MySQL都支持使用DROP语句删除表,但GaussDB(DWS)不支持在DROP语句中使用RESTRICT | CASCADE关键字。DSC工具迁移时会将上述关键字移除。 输入示例 1 2 3 4 5 6 7 CREATE TABLE IF NOT EXISTS `public`.`express_elb_server`( `runoob_id` VARCHAR(10), `runoob_title` VARCHAR(100) NOT NULL, `runoob_author` VARCHAR(40) NOT NULL, `submission_date` VARCHAR(10) )ENGINE=InnoDB DEFAULT CHARSET=utf8; DROP TABLE `public`.`express_elb_server` RESTRICT; 输出示例 1 2 3 4 5 6 7 8 9 10 11 CREATE TABLE IF NOT EXISTS "public"."express_elb_server" ( "runoob_id" VARCHAR(40), "runoob_title" VARCHAR(400) NOT NULL, "runoob_author" VARCHAR(160) NOT NULL, "submission_date" VARCHAR(40) ) WITH ( ORIENTATION = ROW, COMPRESSION = NO ) NOCOMPRESS DISTRIBUTE BY HASH ("runoob_id"); DROP TABLE "public"."express_elb_server"; 父主题: 表(可选参数、操作)
  • UNION UNION 是 MERGE 引擎的建表参数。通过该关键字建表类似于创建普通视图。新创建的表将在逻辑上合并UNION关键字限定的多个表的数据。DSC迁移时会将该特性转为GaussDB视图创建语句。 输入示例 1 2 3 4 5 6 7 8 9 10 11 12 13 14 CREATE TABLE t1 ( a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, message CHAR(20) ) ENGINE=MyISAM; CREATE TABLE t2 ( a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, message CHAR(20) ) ENGINE=MyISAM; CREATE TABLE total ( a INT NOT NULL AUTO_INCREMENT, message CHAR(20)) ENGINE=MyISAM UNION=(t1,t2) INSERT_METHOD=LAST; 输出示例 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 CREATE TABLE "public"."t1" ( "a" SERIAL NOT NULL PRIMARY KEY, "message" CHAR(80) ) WITH ( ORIENTATION = ROW, COMPRESSION = NO ) NOCOMPRESS DISTRIBUTE BY HASH ("a"); CREATE TABLE "public"."t2" ( a SERIAL NOT NULL PRIMARY KEY, message CHAR(80) ) WITH ( ORIENTATION = ROW, COMPRESSION = NO ) NOCOMPRESS DISTRIBUTE BY HASH ("a"); CREATE VIEW "public"."total"(a, message) AS SELECT * FROM "public"."t1" UNION ALL SELECT * FROM "public"."t2"; 父主题: 表(可选参数、操作)
  • STATS_SAMPLE_PAGES STATS_SAMPLE_PAGES指定估计索引列的基数和其他统计信息时要采样的索引页数。DSC迁移时会将该属性删除。 输入示例 1 2 3 4 5 6 7 8 9 CREATE TABLE `public`.`runoob_alter_test`( `dataType1` int NOT NULL AUTO_INCREMENT, `dataType2` DOUBLE(20,8), `dataType3` TEXT NOT NULL, PRIMARY KEY(`dataType1`) ) ENGINE=InnoDB,STATS_SAMPLE_PAGES=25; ALTER TABLE runoob_alter_test STATS_SAMPLE_PAGES 100; ALTER TABLE runoob_alter_test STATS_SAMPLE_PAGES=100; 输出示例 1 2 3 4 5 6 7 8 9 10 CREATE TABLE "public"."runoob_alter_test" ( "datatype1" SERIAL NOT NULL, "datatype2" DOUBLE PRECISION, "datatype3" TEXT NOT NULL, PRIMARY KEY ("datatype1") ) WITH ( ORIENTATION = ROW, COMPRESSION = NO ) NOCOMPRESS DISTRIBUTE BY HASH ("datatype1"); 父主题: 表(可选参数、操作)
  • STATS_PERSISTENT 在MySQL中,STATS_PERSISTENT指定是否为InnoDB表启动持久性统计信息,通过CREATE TABLE或ALTER TABLE语句启动持久性统计信息。DSC迁移时会将该属性删除。 输入示例 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 CREATE TABLE `public`.`runoob_alter_test`( `dataType1` int NOT NULL AUTO_INCREMENT, `dataType2` DOUBLE(20,8), `dataType3` TEXT NOT NULL, PRIMARY KEY(`dataType1`) ) ENGINE=InnoDB, STATS_PERSISTENT=0; ## A. ALTER TABLE runoob_alter_test STATS_PERSISTENT DEFAULT; ALTER TABLE runoob_alter_test STATS_PERSISTENT=DEFAULT; ## B. ALTER TABLE runoob_alter_test STATS_PERSISTENT 0; ALTER TABLE runoob_alter_test STATS_PERSISTENT=0; ## C. ALTER TABLE runoob_alter_test STATS_PERSISTENT 1; ALTER TABLE runoob_alter_test STATS_PERSISTENT=1; 输出示例 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 CREATE TABLE "public"."runoob_alter_test" ( "datatype1" SERIAL NOT NULL, "datatype2" DOUBLE PRECISION, "datatype3" TEXT NOT NULL, PRIMARY KEY ("datatype1") ) WITH ( ORIENTATION = ROW, COMPRESSION = NO ) NOCOMPRESS DISTRIBUTE BY HASH ("datatype1"); -- A. -- B. -- C. 父主题: 表(可选参数、操作)
  • STATS_AUTO_RECALC STATS_AUTO_RECALC指定是否为InnoDB表自动重新计算持久性统计信息。GaussDB(DWS)不支持该属性,DSC迁移时会将该关键字属性。 输入示例 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 CREATE TABLE `public`.`runoob_alter_test`( `runoob_id` VARCHAR(30), `runoob_title` VARCHAR(100) NOT NULL, `runoob_author` VARCHAR(40) NOT NULL, `submission_date` VARCHAR(30) ) ENGINE=InnoDB, STATS_AUTO_RECALC=DEFAULT; ## A. ALTER TABLE runoob_alter_test STATS_AUTO_RECALC DEFAULT; ALTER TABLE runoob_alter_test STATS_AUTO_RECALC=DEFAULT; ## B. ALTER TABLE runoob_alter_test STATS_AUTO_RECALC 0; ALTER TABLE runoob_alter_test STATS_AUTO_RECALC=0; ## C. ALTER TABLE runoob_alter_test STATS_AUTO_RECALC 1; ALTER TABLE runoob_alter_test STATS_AUTO_RECALC=1; 输出示例 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 CREATE TABLE "public"."runoob_alter_test" ( "runoob_id" VARCHAR(120), "runoob_title" VARCHAR(400) NOT NULL, "runoob_author" VARCHAR(160) NOT NULL, "submission_date" VARCHAR(120) ) WITH ( ORIENTATION = ROW, COMPRESSION = NO ) NOCOMPRESS DISTRIBUTE BY HASH ("runoob_id"); -- A. -- B. -- C. 父主题: 表(可选参数、操作)
  • ROW_FORMAT ROW_FORMAT定义了行存储的物理形式。ROW_FORMAT的选择与存储引擎有关,如果在创建表的时候选择了存储引擎不相关的ROW_FORMAT,则使用默认的ROW_FORMAT创建表。当ROW_FORMAT取值为DEFAULT,DSC迁移为SET NOCOMPRESS;当ROW_FORMAT取值为COMPRESSED时,DSC迁移为SET COMPRESS。GaussDB(DWS)不支持其他取值,当取其他值时DSC迁移时会将该属性删除。 输入示例 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 CREATE TABLE `public`.`runoob_alter_test`( `dataType1` int NOT NULL AUTO_INCREMENT, `dataType2` FLOAT(10,2), `dataType3` DOUBLE(20,8), `dataType4` TEXT NOT NULL, PRIMARY KEY(`dataType1`) ) ENGINE=InnoDB; ## A. ALTER TABLE runoob_alter_test ROW_FORMAT DEFAULT; ALTER TABLE runoob_alter_test ROW_FORMAT=DEFAULT; ## B. ALTER TABLE runoob_alter_test ROW_FORMAT DYNAMIC; ALTER TABLE runoob_alter_test ROW_FORMAT=DYNAMIC; ## C. ALTER TABLE runoob_alter_test ROW_FORMAT COMPRESSED; ALTER TABLE runoob_alter_test ROW_FORMAT=COMPRESSED; ## D. ALTER TABLE runoob_alter_test ROW_FORMAT REDUNDANT; ALTER TABLE runoob_alter_test ROW_FORMAT=REDUNDANT; ## E. ALTER TABLE runoob_alter_test ROW_FORMAT COMPACT; ALTER TABLE runoob_alter_test ROW_FORMAT=COMPACT; 输出示例 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 CREATE TABLE "public"."runoob_alter_test" ( "datatype1" SERIAL NOT NULL, "datatype2" REAL, "datatype3" DOUBLE PRECISION, "datatype4" TEXT NOT NULL, PRIMARY KEY ("datatype1") ) WITH ( ORIENTATION = ROW, COMPRESSION = NO ) NOCOMPRESS DISTRIBUTE BY HASH ("datatype1"); -- A. ALTER TABLE "public"."runoob_alter_test" SET NOCOMPRESS; ALTER TABLE "public"."runoob_alter_test" SET NOCOMPRESS; -- B. -- C. ALTER TABLE "public"."runoob_alter_test" SET COMPRESS; ALTER TABLE "public"."runoob_alter_test" SET COMPRESS; -- D. -- E. 父主题: 表(可选参数、操作)
  • PASSWORD 在MySQL中,PASSWORD表示用户密码。GaussDB(DWS)不支持该参数,DSC迁移时会将该关键字删除。 输入示例 1 2 3 4 5 6 7 CREATE TABLE `public`.`runoob_alter_test`( `dataType1` int NOT NULL AUTO_INCREMENT, `dataType2` DOUBLE(20,8), `dataType3` TEXT NOT NULL, PRIMARY KEY(`dataType1`) ); ALTER TABLE runoob_alter_test PASSWORD 'HELLO'; 输出示例 1 2 3 4 5 6 7 8 9 10 CREATE TABLE "public"."runoob_alter_test" ( "datatype1" SERIAL NOT NULL, "datatype2" DOUBLE PRECISION, "datatype3" TEXT NOT NULL, PRIMARY KEY ("datatype1") ) WITH ( ORIENTATION = ROW, COMPRESSION = NO ) NOCOMPRESS DISTRIBUTE BY HASH ("datatype1"); 父主题: 表(可选参数、操作)
  • PARTITION BY LIST 输入示例 1 2 3 4 5 6 7 8 9 10 11 12 13 14 CREATE TABLE IF NOT EXISTS `runoob_tbl_part_test`( `runoob_id` INT NOT NULL, `runoob_title` VARCHAR(100) NOT NULL, `runoob_author` VARCHAR(40) NOT NULL, `submission_date` VARCHAR(30), PRIMARY KEY (`runoob_id`) )ENGINE=InnoDB DEFAULT CHARSET=utf8 PARTITION BY LIST (runoob_id)( PARTITION r0 VALUES IN (1, 5, 9, 13, 17, 21), PARTITION r1 VALUES IN (2, 6, 10, 14, 18, 22), PARTITION r2 VALUES IN (3, 7, 11, 15, 19, 23), PARTITION r3 VALUES IN (4, 8, 12, 16, 20, 24) ); ALTER TABLE `runoob_tbl_part_test` ADD PARTITION (PARTITION p5 VALUES IN(30, 40, 50, 60, 70, 80)); 输出示例 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 CREATE TABLE IF NOT EXISTS "public"."runoob_tbl_part_test" ( "runoob_id" INTEGER NOT NULL, "runoob_title" VARCHAR(400) NOT NULL, "runoob_author" VARCHAR(160) NOT NULL, "submission_date" VARCHAR(120), PRIMARY KEY ("runoob_id") ) WITH (ORIENTATION = ROW, COMPRESSION = NO) NOCOMPRESS DISTRIBUTE BY HASH ("runoob_id") PARTITION BY LIST (runoob_id) ( PARTITION r0 VALUES (1, 5, 9, 13, 17, 21), PARTITION r1 VALUES (2, 6, 10, 14, 18, 22), PARTITION r2 VALUES (3, 7, 11, 15, 19, 23), PARTITION r3 VALUES (4, 8, 12, 16, 20, 24) ); ALTER TABLE "public"."runoob_tbl_part_test" ADD PARTITION p5 VALUES (30, 40, 50, 60, 70, 80);
  • PARTITION BY RANGE 输入示例 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 CREATE TABLE IF NOT EXISTS `runoob_tbl_part_test`( `runoob_id` INT NOT NULL, `runoob_title` VARCHAR(100) NOT NULL, `runoob_author` VARCHAR(40) NOT NULL, `submission_date` VARCHAR(30) )ENGINE=InnoDB DEFAULT CHARSET=utf8 PARTITION BY RANGE (`runoob_id`)( PARTITION p0 VALUES LESS THAN(100), PARTITION p1 VALUES LESS THAN(200), PARTITION p2 VALUES LESS THAN(300), PARTITION p3 VALUES LESS THAN(400), PARTITION p4 VALUES LESS THAN(500), PARTITION p5 VALUES LESS THAN (MAXVALUE) ); ALTER TABLE `runoob_tbl_part_test` ADD PARTITION (PARTITION p6 VALUES LESS THAN (600)); ALTER TABLE `runoob_tbl_part_test` ADD PARTITION (PARTITION p7 VALUES LESS THAN (700),PARTITION p8 VALUES LESS THAN (800)); 输出示例 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 CREATE TABLE IF NOT EXISTS "public"."runoob_tbl_part_test" ( "runoob_id" INTEGER NOT NULL, "runoob_title" VARCHAR(400) NOT NULL, "runoob_author" VARCHAR(160) NOT NULL, "submission_date" VARCHAR(120) ) WITH (ORIENTATION = ROW, COMPRESSION = NO) NOCOMPRESS DISTRIBUTE BY HASH ("runoob_id") PARTITION BY RANGE ("runoob_id") ( PARTITION p0 VALUES LESS THAN (100), PARTITION p1 VALUES LESS THAN (200), PARTITION p2 VALUES LESS THAN (300), PARTITION p3 VALUES LESS THAN (400), PARTITION p4 VALUES LESS THAN (500), PARTITION p5 VALUES LESS THAN (MAXVALUE) ); ALTER TABLE "public"."runoob_tbl_part_test" ADD PARTITION p6 VALUES LESS THAN (600); ALTER TABLE "public"."runoob_tbl_part_test" ADD PARTITION p7 VALUES LESS THAN (700), ADD PARTITION p8 VALUES LESS THAN (800);
  • MAX_ROWS 在MySQL中,MAX_ROWS表示在表中存储的最大行数。DSC迁移过程时会将该属性删除。 输入示例 1 2 3 4 5 6 7 8 9 CREATE TABLE `public`.`runoob_alter_test`( `dataType1` int NOT NULL AUTO_INCREMENT, `dataType2` DOUBLE(20,8), `dataType3` TEXT NOT NULL, PRIMARY KEY(`dataType1`) ); ALTER TABLE runoob_alter_test MAX_ROWS 100000; ALTER TABLE runoob_alter_test MAX_ROWS=100000; 输出示例 1 2 3 4 5 6 7 8 9 10 CREATE TABLE "public"."runoob_alter_test" ( "datatype1" SERIAL NOT NULL, "datatype2" DOUBLE PRECISION, "datatype3" TEXT NOT NULL, PRIMARY KEY ("datatype1") ) WITH ( ORIENTATION = ROW, COMPRESSION = NO ) NOCOMPRESS DISTRIBUTE BY HASH ("datatype1"); 父主题: 表(可选参数、操作)
  • LOCK GaussDB(DWS)不支持MySQL中的“ALTER TABLE tbName LOCK”语句,DSC工具迁移时会将其删除。 输入示例 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 CREATE TABLE IF NOT EXISTS `runoob_alter_test`( `dataType1` int NOT NULL AUTO_INCREMENT, `dataType2` FLOAT(10), `dataType4` TEXT NOT NULL, `dataType5` YEAR NOT NULL DEFAULT '2018', `dataType6` DATETIME NOT NULL, `dataType7` CHAR NOT NULL DEFAULT '', `dataType8` VARCHAR(50), `dataType9` VARCHAR(50) NOT NULL DEFAULT '', `dataType10` TIME NOT NULL DEFAULT '10:20:59', PRIMARY KEY(`dataType1`) )ENGINE=InnoDB DEFAULT CHARSET=utf8; ## A. ALTER TABLE runoob_alter_test LOCK DEFAULT; ## B. ALTER TABLE runoob_alter_test LOCK=DEFAULT; ## C. ALTER TABLE runoob_alter_test LOCK EXCLUSIVE; ## D. ALTER TABLE runoob_alter_test LOCK=EXCLUSIVE; 输出示例 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 CREATE TABLE IF NOT EXISTS "public"."runoob_alter_test" ( "datatype1" SERIAL NOT NULL, "datatype2" REAL, "datatype4" TEXT NOT NULL, "datatype5" SMALLINT NOT NULL DEFAULT '2018', "datatype6" TIMESTAMP WITHOUT TIME ZONE NOT NULL, "datatype7" CHAR(4) NOT NULL DEFAULT '', "datatype8" VARCHAR(200), "datatype9" VARCHAR(200) NOT NULL DEFAULT '', "datatype10" TIME WITHOUT TIME ZONE NOT NULL DEFAULT '10:20:59', PRIMARY KEY ("datatype1") ) WITH ( ORIENTATION = ROW, COMPRESSION = NO ) NOCOMPRESS DISTRIBUTE BY HASH ("datatype1"); -- A. -- B. -- C. -- D. 父主题: 表(可选参数、操作)
  • KEY_BLOCK_SIZE KEY_BLOCK_SIZE的选择与存储引擎有关。对于MyISAM表,KEY_BLOCK_SIZE可选地指定用于索引键块的字节大小。对于InnoDB表,KEY_BLOCK_SIZE指定用于压缩的InnoDB表的页面大小(以KB为单位)。GaussDB(DWS)不支持该属性,DSC迁移时会将属性删除。 输入示例 1 2 3 4 5 6 7 8 9 CREATE TABLE `public`.`runoob_tbl_test`( `runoob_id` VARCHAR(30), `runoob_title` VARCHAR(100) NOT NULL, `runoob_author` VARCHAR(40) NOT NULL, `submission_date` VARCHAR(30) ) ENGINE=MyISAM KEY_BLOCK_SIZE=8; ALTER TABLE runoob_tbl_test ENGINE=InnoDB; ALTER TABLE runoob_tbl_test KEY_BLOCK_SIZE=0; 输出示例 1 2 3 4 5 6 7 8 9 10 CREATE TABLE "public"."runoob_tbl_test" ( "runoob_id" VARCHAR(120), "runoob_title" VARCHAR(400) NOT NULL, "runoob_author" VARCHAR(160) NOT NULL, "submission_date" VARCHAR(120) ) WITH ( ORIENTATION = ROW, COMPRESSION = NO ) NOCOMPRESS DISTRIBUTE BY HASH ("runoob_id"); 父主题: 表(可选参数、操作)
  • INDEX_ALL 在ADB中,创建全列索引index_all='Y'。GaussDB(DWS)不支持该属性修改表定义信息,DSC迁移时会将该属性删除。 输入示例 1 2 3 4 5 6 7 DROP TABLE IF EXISTS unsupport_parse_test; CREATE TABLE `unsupport_parse_test` ( `username` int, `update` timestamp not null default current_timestamp on update current_timestamp , clustered key clustered_key(shopid ASC, datetype ASC) )index_ALL = 'Y'; DROP TABLE IF EXISTS unsupport_parse_test; 输出示例 1 2 3 4 5 6 DROP TABLE IF EXISTS "public"."unsupport_parse_test"; CREATE TABLE "public"."unsupport_parse_test" ( "username" INTEGER, "update" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP ) WITH (ORIENTATION = ROW, COMPRESSION = NO) NOCOMPRESS DISTRIBUTE BY HASH ("username"); DROP TABLE IF EXISTS "public"."unsupport_parse_test"; 父主题: 表(可选参数、操作)
  • IF NOT EXISTS DSC支持转换IF NOT EXISTS关键字,迁移过程保留。 输入示例 1 2 3 4 5 6 7 8 9 10 DROP TABLE IF EXISTS `categories`; CREATE TABLE IF NOT EXISTS `categories` ( `CategoryID` tinyint(5) unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT, `CategoryName` varchar(15) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '' , `Description` mediumtext CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL , `Picture` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '', UNIQUE (`CategoryID`) )ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=latin1; DROP TABLE IF EXISTS `categories`; 输出示例 1 2 3 4 5 6 7 8 DROP TABLE IF EXISTS "public"."categories"; CREATE TABLE IF NOT EXISTS "public"."categories" ( "categoryid" SMALLSERIAL NOT NULL PRIMARY KEY, "categoryname" VARCHAR(60) NOT NULL DEFAULT '', "description" TEXT NOT NULL, "picture" VARCHAR(200) NOT NULL DEFAULT '' ) WITH (ORIENTATION = ROW, COMPRESSION = NO) NOCOMPRESS DISTRIBUTE BY HASH ("categoryid"); DROP TABLE IF EXISTS "public"."categories"; 父主题: 表(可选参数、操作)
  • FOREIGN_KEY_CHECKS MySQL中的外键约束,GaussDB(DWS)不支持该属性修改表定义信息,DSC迁移时会将该属性删除。 输入示例 1 2 3 4 5 6 SET foreign_key_checks = 0; CREATE TABLE mall_order_dc ( id bigint NOT NULL AUTO_INCREMENT, order_id varchar(50) NOT NULL, key order_id(order_id) ); 输出示例 1 2 3 4 5 CREATE TABLE "public"."mall_order_dc" ( "id" BIGSERIAL NOT NULL, "order_id" VARCHAR(200) NOT NULL ) WITH (ORIENTATION = ROW, COMPRESSION = NO) NOCOMPRESS DISTRIBUTE BY HASH ("id"); CREATE INDEX "order_id" ON "public"."mall_order_dc" USING BTREE ("order_id"); 父主题: 表(可选参数、操作)
  • ENGINE 在MySQL中,ENGINE指定表的存储引擎。当存储引擎为ARCHIVE、BLACKHOLE、 CS V、FEDERATED、INNODB、MYISAM、MEMORY、MRG_MYISAM、NDB、NDBCLUSTER和PERFOMANCE_SCHEMA时,DSC支持该属性迁移,迁移过程中会将该属性删除。 输入示例 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 CREATE TABLE `public`.`runoob_alter_test`( `dataType1` int NOT NULL, `dataType2` DOUBLE(20,8), PRIMARY KEY(`dataType1`) )ENGINE=MYISAM; ## A. ALTER TABLE runoob_alter_test ENGINE INNODB; ALTER TABLE runoob_alter_test ENGINE=INNODB; ## B. ALTER TABLE runoob_alter_test ENGINE MYISAM; ALTER TABLE runoob_alter_test ENGINE=MYISAM; ## C. ALTER TABLE runoob_alter_test ENGINE MEMORY; ALTER TABLE runoob_alter_test ENGINE=MEMORY; 输出示例 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 CREATE TABLE "public"."runoob_alter_test" ( "datatype1" INTEGER NOT NULL, "datatype2" DOUBLE PRECISION, PRIMARY KEY ("datatype1") ) WITH ( ORIENTATION = ROW, COMPRESSION = NO ) NOCOMPRESS DISTRIBUTE BY HASH ("datatype1"); -- A. -- B. -- C. 父主题: 表(可选参数、操作)
  • DIRECTORY DIRECTORY表示允许在数据目录和索引目录之外创建表空间。DIRECTORY包含DATA DIRECTORY和INDEX DIRECTORY。GaussDB(DWS)不支持该属性修改表定义信息,DSC迁移时会将该属性删除。 输入示例 1 2 3 4 5 6 7 8 9 10 11 CREATE TABLE `public`.`runoob_tbl_test1` ( `dataType1` int NOT NULL AUTO_INCREMENT, `dataType2` DOUBLE(20,8), PRIMARY KEY(`dataType1`) ) ENGINE=MYISAM DATA DIRECTORY = 'D:\\input' INDEX DIRECTORY= 'D:\\input'; CREATE TABLE `public`.`runoob_tbl_test2` ( `dataType1` int NOT NULL AUTO_INCREMENT, `dataType2` DOUBLE(20,8), PRIMARY KEY(`dataType1`) ) ENGINE=INNODB DATA DIRECTORY = 'D:\\input'; 输出示例 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 CREATE TABLE "public"."runoob_tbl_test1" ( "datatype1" SERIAL NOT NULL, "datatype2" DOUBLE PRECISION, PRIMARY KEY ("datatype1") ) WITH ( ORIENTATION = ROW, COMPRESSION = NO ) NOCOMPRESS DISTRIBUTE BY HASH ("datatype1"); CREATE TABLE "public"."runoob_tbl_test2" ( "datatype1" SERIAL NOT NULL, "datatype2" DOUBLE PRECISION, PRIMARY KEY ("datatype1") ) WITH ( ORIENTATION = ROW, COMPRESSION = NO ) NOCOMPRESS DISTRIBUTE BY HASH ("datatype1"); 父主题: 表(可选参数、操作)
  • DISTRIBUTE BY 在ADB中支持分布键,DSC迁移过程中会保留对应分布键。 输入示例 1 2 3 4 5 6 7 CREATE TABLE COPY_DI_DISTRIBUTOR_BUYER_CONTRIBUTION_RANKING_V2 ( SHOP_ID VARCHAR , DISTRIBUTOR_ID VARCHAR , BUYER_ID VARCHAR , DATE_TYPE BIGINT , PRIMARY KEY (SHOP_ID,DISTRIBUTOR_ID,DATE_TYPE,BUYER_ID) ) DISTRIBUTE BY HASH(SHOP_ID,DISTRIBUTOR_ID,DATE_TYPE); 输出示例 1 2 3 4 5 6 7 8 9 10 11 12 CREATE TABLE "public"."copy_di_distributor_buyer_contribution_ranking_v2" ( "shop_id" VARCHAR, "distributor_id" VARCHAR, "buyer_id" VARCHAR, "date_type" BIGINT, PRIMARY KEY ( "shop_id", "distributor_id", "date_type", "buyer_id" ) ) WITH (ORIENTATION = ROW, COMPRESSION = NO) NOCOMPRESS DISTRIBUTE BY HASH (SHOP_ID, DISTRIBUTOR_ID, DATE_TYPE); 父主题: 表(可选参数、操作)
  • DELAY_KEY_WRITE DELAY_KEY_WRITE只对MyISAM引擎表有作用,根据DELAY_KEY_WRITE的值来延迟更新直至表关闭。GaussDB(DWS)不支持该属性修改表定义信息,DSC迁移时会将该属性删除。 输入示例 1 2 3 4 5 6 7 8 CREATE TABLE `public`.`runoob_tbl_test`( `runoob_id` VARCHAR(30), `runoob_title` VARCHAR(100) NOT NULL, `runoob_author` VARCHAR(40) NOT NULL, `submission_date` VARCHAR(30) ) ENGINE=MyISAM, DELAY_KEY_WRITE=0; ALTER TABLE `public`.`runoob_tbl_test6` DELAY_KEY_WRITE=1; 输出示例 1 2 3 4 5 6 7 8 9 10 CREATE TABLE "public"."runoob_tbl_test" ( "runoob_id" VARCHAR(120), "runoob_title" VARCHAR(400) NOT NULL, "runoob_author" VARCHAR(160) NOT NULL, "submission_date" VARCHAR(120) ) WITH ( ORIENTATION = ROW, COMPRESSION = NO ) NOCOMPRESS DISTRIBUTE BY HASH ("runoob_id"); 父主题: 表(可选参数、操作)
  • CONNECTION GaussDB(DWS)不支持该属性修改表定义信息,DSC迁移时会将该属性删除。 CONNECTION关键字在MySQL中用作引用外部数据源。工具暂不支持该特性的完整迁移。基于当前的临时方案,工具仅仅移除该关键字。 输入示例 1 2 3 4 5 6 7 8 9 10 CREATE TABLE `public`.`runoob_alter_test`( `dataType1` int NOT NULL AUTO_INCREMENT, `dataType2` DOUBLE(20,8), `dataType3` TEXT NOT NULL, `dataType4` YEAR NOT NULL DEFAULT '2018', PRIMARY KEY(`dataType1`) ); ALTER TABLE runoob_alter_test CONNECTION 'hello'; ALTER TABLE runoob_alter_test CONNECTION='hello'; 输出示例 1 2 3 4 5 6 7 8 9 10 11 CREATE TABLE "public"."runoob_alter_test" ( "datatype1" SERIAL NOT NULL, "datatype2" DOUBLE PRECISION, "datatype3" TEXT NOT NULL, "datatype4" SMALLINT NOT NULL DEFAULT '2018', PRIMARY KEY ("datatype1") ) WITH ( ORIENTATION = ROW, COMPRESSION = NO ) NOCOMPRESS DISTRIBUTE BY HASH ("datatype1"); 父主题: 表(可选参数、操作)
  • COMMENT 在MySQL中,COMMENT对表进行注释。GaussDB(DWS)支持该属性修改表定义信息,DSC工具迁移时会添加额外的表属性信息。 输入示例 1 2 3 4 5 6 7 8 CREATE TABLE `public`.`runoob_alter_test`( `dataType1` int NOT NULL AUTO_INCREMENT, `dataType2` FLOAT(10,2) COMMENT 'dataType2列', PRIMARY KEY(`dataType1`) ) comment='表的注释'; ALTER TABLE `public`.`runoob_alter_test` COMMENT '修改后的表的注释'; ALTER TABLE `public`.`runoob_alter_test` ADD INDEX age_index(dataType2) COMMENT '索引'; 输出示例 1 2 3 4 5 6 7 8 9 10 11 12 CREATE TABLE "public"."runoob_alter_test" ( "datatype1" SERIAL NOT NULL, "datatype2" REAL COMMENT 'dataType2列', PRIMARY KEY ("datatype1") ) WITH ( ORIENTATION = ROW, COMPRESSION = NO ) NOCOMPRESS DISTRIBUTE BY HASH ("datatype1") COMMENT '表的注释'; ALTER TABLE "public"."runoob_alter_test" COMMENT '修改后的表的注释'; CREATE INDEX "age_index" ON "public"."runoob_alter_test" ("dataType2") COMMENT '索引'; 父主题: 表(可选参数、操作)
  • COLLATE 在MySQL中,COLLATE表示默认的数据库排序规则。GaussDB(DWS)不支持该属性修改表定义信息,DSC迁移时会将该关键字删除。 输入示例 1 2 3 4 5 6 7 8 CREATE TABLE `public`.`runoob_tbl_test`( `runoob_id` VARCHAR(30), `runoob_title` VARCHAR(100) NOT NULL, `runoob_author` VARCHAR(40) NOT NULL, `submission_date` VARCHAR(30) ) COLLATE=utf8_general_ci; ALTER TABLE `public`.`runoob_tbl_test` COLLATE=utf8mb4_bin; 输出示例 1 2 3 4 5 6 7 8 9 10 CREATE TABLE "public"."runoob_tbl_test" ( "runoob_id" VARCHAR(120), "runoob_title" VARCHAR(400) NOT NULL, "runoob_author" VARCHAR(160) NOT NULL, "submission_date" VARCHAR(120) ) WITH ( ORIENTATION = ROW, COMPRESSION = NO ) NOCOMPRESS DISTRIBUTE BY HASH ("runoob_id"); 父主题: 表(可选参数、操作)
  • CLUSTERED KEY 在ADB中,CLUSTERED KEY:聚集索引,定义表中的排序列,聚集索引中键值的逻辑顺序决定了表中相应行的物理顺序。GaussDB(DWS)不支持该属性修改表定义信息,DSC迁移时会将该关键字删除。 输入示例 1 2 3 4 5 6 DROP TABLE IF EXISTS unsupport_parse_test; CREATE TABLE `unsupport_parse_test` ( `username` int, clustered key clustered_key(shopid ASC, datetype ASC) ); DROP TABLE IF EXISTS unsupport_parse_test; 输出示例 1 2 3 4 5 DROP TABLE IF EXISTS "public"."unsupport_parse_test"; CREATE TABLE "public"."unsupport_parse_test" ( "username" INTEGER ) WITH (ORIENTATION = ROW, COMPRESSION = NO) NOCOMPRESS DISTRIBUTE BY HASH ("username"); DROP TABLE IF EXISTS "public"."unsupport_parse_test"; 父主题: 表(可选参数、操作)
  • AVG_ROW_LENGTH 在MySQL中,AVG_ROW_LENGTH表示平均每行的长度。 GaussDB(DWS)不支持此属性,并在迁移过程中被DSC删除。 输入示例 1 2 3 4 5 6 CREATE TABLE `public`.`runoob_tbl_test`( `runoob_id` VARCHAR(30), `runoob_title` VARCHAR(100) NOT NULL, `runoob_author` VARCHAR(40) NOT NULL, `submission_date` VARCHAR(30) )AVG_ROW_LENGTH=10000; 输出示例 1 2 3 4 5 6 7 8 9 10 CREATE TABLE "public"."runoob_tbl_test" ( "runoob_id" VARCHAR(120), "runoob_title" VARCHAR(400) NOT NULL, "runoob_author" VARCHAR(160) NOT NULL, "submission_date" VARCHAR(120) ) WITH ( ORIENTATION = ROW, COMPRESSION = NO ) NOCOMPRESS DISTRIBUTE BY HASH ("runoob_id"); 父主题: 表(可选参数、操作)
  • AUTO_INCREMENT 在数据库应用中,我们经常需要用到自动递增的唯一编号来标识记录。在MySQL中,可通过数据列的auto_increment属性来自动生成。可在建表时可用“auto_increment=n”选项来指定一个自增的初始值。可用“alter table table_name auto_increment=n”命令来重设自增的起始值。GaussDB(DWS)不支持该参数,DSC迁移时会将设置该属性的字段迁移为SERIAL类型,并删除该关键字,转换如下表。 表1 数据类型转换 MySQL数字类型 MySQL INPUT GaussDB(DWS) OUTPUT TINYINT TINYINT SMALLSERIAL SMALLINT SMALLINT UNSIGNED SMALLINT SERIAL SMALLSERIAL DOUBLE/FLOAT DOUBLE/FLOAT BIGSERIAL INT/INTEGER INT/INTEGER UNSIGNED INT/INTEGER BIGSERIAL SERIAL BIGINT/SERIAL BIGINT/SERIAL BIGSERIAL 输入示例 1 2 3 4 5 CREATE TABLE `public`.`job_instance` ( `job_sche_id` int(11) NOT NULL AUTO_INCREMENT, `task_name` varchar(100) NOT NULL DEFAULT '', PRIMARY KEY (`job_sche_id`) ) ENGINE=InnoDB AUTO_INCREMENT=219 DEFAULT CHARSET=utf8; 输出示例 1 2 3 4 5 6 7 8 9 CREATE TABLE "public"."job_instance" ( "job_sche_id" SERIAL NOT NULL, "task_name" VARCHAR(400) NOT NULL DEFAULT '', PRIMARY KEY ("job_sche_id") ) WITH ( ORIENTATION = ROW, COMPRESSION = NO ) NOCOMPRESS DISTRIBUTE BY HASH ("job_sche_id"); 此外,GaussDB(DWS)也不支持基于AUTO_INCREMENT属性修改表定义信息。DSC迁移时会将其移除。 输入示例 1 2 3 4 5 6 7 8 CREATE TABLE IF NOT EXISTS `public`.`runoob_alter_test`( `dataType1` int NOT NULL AUTO_INCREMENT, `dataType2` FLOAT(10,2), PRIMARY KEY(`dataType1`) ); ALTER TABLE runoob_alter_test AUTO_INCREMENT 100; ALTER TABLE runoob_alter_test AUTO_INCREMENT=100; 输出示例 1 2 3 4 5 6 7 8 9 CREATE TABLE IF NOT EXISTS "public"."runoob_alter_test" ( "datatype1" SERIAL NOT NULL, "datatype2" REAL, PRIMARY KEY ("datatype1") ) WITH ( ORIENTATION = ROW, COMPRESSION = NO ) NOCOMPRESS DISTRIBUTE BY HASH ("datatype1"); 父主题: 表(可选参数、操作)
  • ALTER TABLE RENAME GaussDB(DWS)不支持rename子句包含schema名,因此DSC工具只支持同schema下的rename。同schema下rename,转换结果去掉子句schema,跨schema的rename报错。 输入示例 1 2 3 4 ALTER TABLE `shce1`.`t1` rename to `t2`; ALTER TABLE `shce1`.`t1` rename to t2; ALTER TABLE `charge_data`.`group_shengfen2022` RENAME `charge_data`.`group_shengfen2022_jiu`; ALTER TABLE `charge_data`.`group_shengfen2022` RENAME `charge_data`.`group_shengfen2022_jiu`, RENAME `charge_data`.`group_shengfen2023_jiu`, RENAME `charge_data`.`group_shengfen2024_jiu`; 输出示例 1 2 3 4 ALTER TABLE "shce1"."t1" RENAME TO "t2"; ALTER TABLE "shce1"."t1" RENAME TO "t2"; ALTER TABLE "charge_data"."group_shengfen2022" RENAME TO "group_shengfen2022_jiu"; ALTER TABLE "charge_data"."group_shengfen2022" RENAME TO "group_shengfen2022_jiu", RENAME TO "group_shengfen2023_jiu", RENAME TO "group_shengfen2024_jiu"; 父主题: 表(可选参数、操作)
共100000条