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

SPATIAL空间索引

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

GaussDB A 不支持 SPATIAL空间索引。DSC工具迁移时会根据GaussDB的特性进行相应适配。

  1. 内联SPATIAL空间索引

    输入示例

    CREATE TABLE `public`.`test_create_table04` (
    	`ID` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
    	`A` POINT NOT NULL,
    	`B` POLYGON NOT NULL,
    	`C` GEOMETRYCOLLECTION NOT NULL,
    	`D` LINESTRING NOT NULL,
    	`E` MULTILINESTRING NOT NULL,
    	`F` MULTIPOINT NOT NULL,
    	`G` MULTIPOLYGON NOT NULL,
    	SPATIAL INDEX A_INDEX(A),
    	SPATIAL INDEX B_INDEX(B),
    	SPATIAL INDEX C_INDEX(C),
    	SPATIAL KEY D_INDEX(D),
    	SPATIAL KEY E_INDEX(E),
    	SPATIAL KEY F_INDEX(F),
    	SPATIAL INDEX G_INDEX(G)
    );

    输出示例

    CREATE TABLE "public"."test_create_table04"
    (
      "id" SERIAL NOT NULL PRIMARY KEY,
      "a" POINT NOT NULL,
      "b" POLYGON NOT NULL,
      "c" CIRCLE NOT NULL,
      "d" POLYGON NOT NULL,
      "e" BOX NOT NULL,
      "f" BOX NOT NULL,
      "g" POLYGON NOT NULL
    )
      WITH ( ORIENTATION = ROW, COMPRESSION = NO )
      NOCOMPRESS
      DISTRIBUTE BY HASH ("id");
    CREATE INDEX "a_index" ON "public"."test_create_table04" USING GIST ("a");
    CREATE INDEX "b_index" ON "public"."test_create_table04" USING GIST ("b");
    CREATE INDEX "c_index" ON "public"."test_create_table04" USING GIST ("c");
    CREATE INDEX "d_index" ON "public"."test_create_table04" USING GIST ("d");
    CREATE INDEX "e_index" ON "public"."test_create_table04" USING GIST ("e");
    CREATE INDEX "f_index" ON "public"."test_create_table04" USING GIST ("f");
    CREATE INDEX "g_index" ON "public"."test_create_table04" USING GIST ("g");
  2. ALTER TABLE创建SPATIAL空间索引

    输入示例

    CREATE TABLE `public`.`test_create_table04` (
     `ID` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
     `A` POINT NOT NULL,
     `B` POLYGON NOT NULL,
     `C` GEOMETRYCOLLECTION NOT NULL,
     `D` LINESTRING NOT NULL,
     `E` MULTILINESTRING NOT NULL,
     `F` MULTIPOINT NOT NULL,
     `G` MULTIPOLYGON NOT NULL
    );
    
    ALTER TABLE `test_create_table04` ADD SPATIAL INDEX A_INDEX(A);
    ALTER TABLE `test_create_table04` ADD SPATIAL INDEX E_INDEX(E) USING BTREE;

    输出示例

    CREATE TABLE "public"."test_create_table04"
    (
      "id" SERIAL NOT NULL PRIMARY KEY,
      "a" POINT NOT NULL,
      "b" POLYGON NOT NULL,
      "c" CIRCLE NOT NULL,
      "d" POLYGON NOT NULL,
      "e" BOX NOT NULL,
      "f" BOX NOT NULL,
      "g" POLYGON NOT NULL
    )
      WITH ( ORIENTATION = ROW, COMPRESSION = NO )
      NOCOMPRESS
      DISTRIBUTE BY HASH ("id");
    
    CREATE INDEX "a_index" ON "public"."test_create_table04" USING GIST ("a");
    CREATE INDEX "e_index" ON "public"."test_create_table04" USING GIST ("e");
  3. CREATE INDEX创建SPATIAL空间索引

    输入示例

    CREATE TABLE `public`.`test_create_table04` (
    	`ID` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
    	`A` POINT NOT NULL,
    	`B` POLYGON NOT NULL,
    	`C` GEOMETRYCOLLECTION NOT NULL,
    	`D` LINESTRING NOT NULL,
    	`E` MULTILINESTRING NOT NULL,
    	`F` MULTIPOINT NOT NULL,
    	`G` MULTIPOLYGON NOT NULL
    );
    
    CREATE SPATIAL INDEX A_INDEX ON `test_create_table04`(A);

    输出示例

    CREATE TABLE "public"."test_create_table04"
    (
      "id" SERIAL NOT NULL PRIMARY KEY,
      "a" POINT NOT NULL,
      "b" POLYGON NOT NULL,
      "c" CIRCLE NOT NULL,
      "d" POLYGON NOT NULL,
      "e" BOX NOT NULL,
      "f" BOX NOT NULL,
      "g" POLYGON NOT NULL
    )
      WITH ( ORIENTATION = ROW, COMPRESSION = NO )
      NOCOMPRESS
      DISTRIBUTE BY HASH ("id");
    
    CREATE INDEX "a_index" ON "public"."test_create_table04" USING GIST ("a");

分享:

    相关文档

    相关产品

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

提交成功!

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

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

*必选

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

字符长度不能超过200

提交反馈 取消

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

智能客服提问云社区提问