forked from docs/doc-exports
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com> Reviewed-by: Jiang, Beibei <beibei.jiang@t-systems.com> Co-authored-by: Lu, Huayi <luhuayi@huawei.com> Co-committed-by: Lu, Huayi <luhuayi@huawei.com>
106 lines
7.3 KiB
HTML
106 lines
7.3 KiB
HTML
<a name="EN-US_TOPIC_0000001188681078"></a><a name="EN-US_TOPIC_0000001188681078"></a>
|
|
|
|
<h1 class="topictitle1">B-tree Indexes</h1>
|
|
<div id="body8662426"><p id="EN-US_TOPIC_0000001188681078__en-us_topic_0238518445_en-us_topic_0237362219_en-us_topic_0214164417_p330274862511"><span id="EN-US_TOPIC_0000001188681078__text10892754124514">GaussDB(DWS)</span> supports B-tree indexes, but the position of the <strong id="EN-US_TOPIC_0000001188681078__en-us_topic_0237712383_b1068817542486">USING BTREE</strong> keyword in a statement is different from that in MySQL. DSC will perform adaptation based on GaussDB features during migration.</p>
|
|
<ol id="EN-US_TOPIC_0000001188681078__en-us_topic_0238518445_en-us_topic_0237362219_en-us_topic_0214164417_ol12553123692615"><li id="EN-US_TOPIC_0000001188681078__en-us_topic_0238518445_en-us_topic_0237362219_en-us_topic_0214164417_li15553183615265">Inline B-tree index<p id="EN-US_TOPIC_0000001188681078__en-us_topic_0238518445_en-us_topic_0237362219_en-us_topic_0214164417_p135691921172717"><a name="EN-US_TOPIC_0000001188681078__en-us_topic_0238518445_en-us_topic_0237362219_en-us_topic_0214164417_li15553183615265"></a><a name="en-us_topic_0238518445_en-us_topic_0237362219_en-us_topic_0214164417_li15553183615265"></a><strong id="EN-US_TOPIC_0000001188681078__en-us_topic_0237712383_b9688754114817">Input</strong></p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001188681078__en-us_topic_0238518445_en-us_topic_0237362219_en-us_topic_0214164417_screen182799185276">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 THEME_INDEX(THEME) USING BTREE,
|
|
INDEX NAME_INDEX USING BTREE (SEND_NAME(10))
|
|
);</pre>
|
|
<p id="EN-US_TOPIC_0000001188681078__en-us_topic_0238518445_en-us_topic_0237362219_en-us_topic_0214164417_p77858251279"><strong id="EN-US_TOPIC_0000001188681078__en-us_topic_0237712383_b9688195413486">Output</strong></p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001188681078__en-us_topic_0238518445_en-us_topic_0237362219_en-us_topic_0214164417_screen71919285272">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 "theme_index" ON "public"."test_create_table03" USING BTREE ("theme");
|
|
CREATE INDEX "name_index" ON "public"."test_create_table03" USING BTREE ("send_name");</pre>
|
|
</li><li id="EN-US_TOPIC_0000001188681078__en-us_topic_0238518445_en-us_topic_0237362219_en-us_topic_0214164417_li19672194516269">B-tree index created by <strong id="EN-US_TOPIC_0000001188681078__en-us_topic_0237712383_b18690554204812">ALTER TABLE</strong><p id="EN-US_TOPIC_0000001188681078__en-us_topic_0238518445_en-us_topic_0237362219_en-us_topic_0214164417_p1287443289"><strong id="EN-US_TOPIC_0000001188681078__en-us_topic_0237712383_b56900548487">Input</strong></p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001188681078__en-us_topic_0238518445_en-us_topic_0237362219_en-us_topic_0214164417_screen9287164132817">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 ADD KEY alterTable_addKey_indexType (dataType1) USING BTREE;</pre>
|
|
<p id="EN-US_TOPIC_0000001188681078__en-us_topic_0238518445_en-us_topic_0237362219_en-us_topic_0214164417_p142870442811"><strong id="EN-US_TOPIC_0000001188681078__en-us_topic_0237712383_b6690105434813">Output</strong></p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001188681078__en-us_topic_0238518445_en-us_topic_0237362219_en-us_topic_0214164417_screen19288648288">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");</pre>
|
|
</li><li id="EN-US_TOPIC_0000001188681078__en-us_topic_0238518445_en-us_topic_0237362219_en-us_topic_0214164417_li1937655815268">B-tree index created by <strong id="EN-US_TOPIC_0000001188681078__en-us_topic_0237712383_b176901054124817">CREATE INDEX</strong><p id="EN-US_TOPIC_0000001188681078__en-us_topic_0238518445_en-us_topic_0237362219_en-us_topic_0214164417_p15863552819"><strong id="EN-US_TOPIC_0000001188681078__en-us_topic_0237712383_b1269055404817">Input</strong></p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001188681078__en-us_topic_0238518445_en-us_topic_0237362219_en-us_topic_0214164417_screen758620572815">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_index_table05` (
|
|
`ID` INT(11) NOT NULL AUTO_INCREMENT,
|
|
`USER_ID` INT(20) NOT NULL,
|
|
`USER_NAME` CHAR(20) NULL DEFAULT NULL,
|
|
`DETAIL` VARCHAR(100) NULL DEFAULT NULL,
|
|
PRIMARY KEY (`ID`)
|
|
);
|
|
CREATE UNIQUE INDEX USER_ID_INDEX USING BTREE ON TEST_INDEX_TABLE05(USER_ID);
|
|
CREATE INDEX USER_NAME_INDEX USING BTREE ON TEST_INDEX_TABLE05(USER_NAME(10));
|
|
CREATE INDEX DETAIL_INDEX ON TEST_INDEX_TABLE05(DETAIL(50)) USING BTREE;
|
|
CREATE INDEX USER_INFO_INDEX USING BTREE ON TEST_INDEX_TABLE05(USER_ID,USER_NAME(10));</pre>
|
|
<p id="EN-US_TOPIC_0000001188681078__en-us_topic_0238518445_en-us_topic_0237362219_en-us_topic_0214164417_p35869514281"><strong id="EN-US_TOPIC_0000001188681078__en-us_topic_0237712383_b1169185412488">Output</strong></p>
|
|
<pre class="screen" id="EN-US_TOPIC_0000001188681078__en-us_topic_0238518445_en-us_topic_0237362219_en-us_topic_0214164417_screen8586145162813">CREATE TABLE "public"."test_index_table05"
|
|
(
|
|
"id" SERIAL NOT NULL,
|
|
"user_id" INTEGER(20) NOT NULL,
|
|
"user_name" CHAR(20) DEFAULT NULL,
|
|
"detail" VARCHAR(100) DEFAULT NULL,
|
|
PRIMARY KEY ("id")
|
|
)
|
|
WITH ( ORIENTATION = ROW, COMPRESSION = NO )
|
|
NOCOMPRESS
|
|
DISTRIBUTE BY HASH ("id");
|
|
CREATE INDEX "user_id_index" ON "public"."test_index_table05" ("user_id");
|
|
CREATE INDEX "user_name_index" ON "public"."test_index_table05" USING BTREE ("user_name");
|
|
CREATE INDEX "detail_index" ON "public"."test_index_table05" USING BTREE ("detail");
|
|
CREATE INDEX "user_info_index" ON "public"."test_index_table05" USING BTREE ("user_id","user_name");</pre>
|
|
</li></ol>
|
|
<p id="EN-US_TOPIC_0000001188681078__en-us_topic_0238518445_en-us_topic_0237362219_en-us_topic_0214164417_p8060118"></p>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_sct_0013.html">MySQL Syntax Migration</a></div>
|
|
</div>
|
|
</div>
|
|
|