文档首页 > > 工具指南> DSC SQL语法迁移工具> SQL语法迁移参考> MySQL语法迁移> HASH索引

HASH索引

分享
更新时间:2020/08/05 GMT+08:00

GaussDB A 不支持 HASH 索引。DSC工具迁移时会根据GaussDB的特性将其迁移为普通索引。

  1. 内联HASH索引

    输入示例

    CREATE TABLE `public`.`test_create_table03` (
    	`DEMAND_ID` INT(11) NOT NULL AUTO_INCREMENT,
    	`DEMAND_NAME` CHAR(100) NOT NULL,
    	`THEME` VARCHAR(200) NULL DEFAULT NULL,
    	`SEND_ID` INT(11) NULL DEFAULT NULL,
    	`SEND_NAME` CHAR(20) NULL DEFAULT NULL,
    	`SEND_TIME` DATETIME NULL DEFAULT NULL,
    	`DEMAND_CONTENT` TEXT NOT NULL,
    	PRIMARY KEY(`DEMAND_ID`),
        INDEX CON_INDEX(DEMAND_CONTENT(100)) USING HASH ,
        INDEX SEND_INFO_INDEX USING HASH (SEND_ID,SEND_NAME(10),SEND_TIME)
    );

    输出示例

    CREATE TABLE "public"."test_create_table03"
    (
      "demand_id" SERIAL NOT NULL,
      "demand_name" CHAR(100) NOT NULL,
      "theme" VARCHAR(200) DEFAULT NULL,
      "send_id" INTEGER(11) DEFAULT NULL,
      "send_name" CHAR(20) DEFAULT NULL,
      "send_time" TIMESTAMP WITHOUT TIME ZONE DEFAULT NULL,
      "demand_content" TEXT NOT NULL,
      PRIMARY KEY ("demand_id")
    )
      WITH ( ORIENTATION = ROW, COMPRESSION = NO )
      NOCOMPRESS
      DISTRIBUTE BY HASH ("demand_id");
    CREATE INDEX "con_index" ON "public"."test_create_table03" ("demand_content");
    CREATE INDEX "send_info_index" ON "public"."test_create_table03" ("send_id","send_name","send_time");
  2. ALTER TABLE创建HASH索引

    输入示例

    CREATE TABLE IF NOT EXISTS `public`.`runoob_alter_test`(
        `dataType1` int NOT NULL AUTO_INCREMENT,
        `dataType2` FLOAT(10,2),
        PRIMARY KEY(`dataType1`)
    )ENGINE=InnoDB DEFAULT CHARSET=utf8;
    
    ALTER TABLE runoob_alter_test ADD KEY alterTable_addKey_indexType(dataType1) USING HASH;

    输出示例

    CREATE TABLE "public"."runoob_alter_test"
    (
      "datatype1" SERIAL NOT NULL,
      "datatype2" FLOAT(10),
      PRIMARY KEY ("datatype1")
    )
      WITH ( ORIENTATION = ROW, COMPRESSION = NO )
      NOCOMPRESS
      DISTRIBUTE BY HASH ("datatype1");
    
    CREATE INDEX "altertable_addkey_indextype" ON "public"."runoob_alter_test" ("datatype1");
  3. CREATE INDEX创建HASH索引

    输入示例

    CREATE TABLE `public`.`test_index_table06` (
    	`ID` INT(11) NOT NULL AUTO_INCREMENT,
    	`FNAME` VARCHAR(30) NOT NULL,
    	`INAME` VARCHAR(30) NOT NULL,
    	PRIMARY KEY (`ID`)
    );
    CREATE INDEX FNAME_INDEX ON TEST_INDEX_TABLE06(FNAME(10)) USING HASH;
    CREATE INDEX NAME_01 ON TEST_INDEX_TABLE06(FNAME(10),INAME(10)) USING HASH;

    输出示例

    CREATE TABLE "public"."test_index_table06"
    (
      "id" SERIAL NOT NULL,
      "fname" VARCHAR(30) NOT NULL,
      "iname" VARCHAR(30) NOT NULL,
      PRIMARY KEY ("id")
    )
      WITH ( ORIENTATION = ROW, COMPRESSION = NO )
      NOCOMPRESS
      DISTRIBUTE BY HASH ("id");
    CREATE INDEX "fname_index" ON "public"."test_index_table06" ("fname");
    CREATE INDEX "name_01" ON "public"."test_index_table06" ("fname","iname");
分享:

    相关文档

    相关产品

文档是否有解决您的问题?

提交成功!

非常感谢您的反馈,我们会继续努力做到更好!

反馈提交失败,请稍后再试!

*必选

请至少选择或填写一项反馈信息

字符长度不能超过200

提交反馈 取消

如您有其它疑问,您也可以通过华为云社区问答频道来与我们联系探讨

智能客服提问云社区提问