您好,登錄后才能下訂單哦!
DM7數(shù)組索引的概念是什么,相信很多沒(méi)有經(jīng)驗(yàn)的人對(duì)此束手無(wú)策,為此本文總結(jié)了問(wèn)題出現(xiàn)的原因和解決方法,通過(guò)這篇文章希望你能解決這個(gè)問(wèn)題。
數(shù)組索引指在一個(gè)只包含單個(gè)數(shù)組成員的對(duì)象列上創(chuàng)建的索引。
數(shù)組索引定義語(yǔ)句
語(yǔ)法格式
CREATE ARRAY INDEX < 索引名> ON [< 模式名>.] < 表名> (< 索引列定義>)
使用說(shuō)明
1) 暫不支持在水平分區(qū)表上創(chuàng)建數(shù)組索引;
2) 暫時(shí)不支持在有數(shù)組索引表上進(jìn)行批量裝載(數(shù)組索引失效的例外);
3) 支持創(chuàng)建數(shù)組索引的對(duì)象只能包含數(shù)組一個(gè)成員。數(shù)組可以是DM靜態(tài)數(shù)組、動(dòng)態(tài)數(shù)組或者ORACLE兼容的嵌套表或VARRAY;
4) 數(shù)組項(xiàng)類(lèi)型只能是可比較的標(biāo)量類(lèi)型,不支持復(fù)合類(lèi)型、對(duì)象類(lèi)型或大字段類(lèi)型;
5) 臨時(shí)表、垂直分區(qū)表不支持;
6) 數(shù)組索引不支持改名;
7) 數(shù)組索引列不支持改名;
8) 數(shù)組索引只能是單索引,不能為組合索引;
9) 不支持空值的檢索
10) MPP環(huán)境不支持?jǐn)?shù)組索引。
數(shù)組索引修改語(yǔ)句
數(shù)組索引修改語(yǔ)句與普通索引用法相同,請(qǐng)參考3.7節(jié)。與普通索引不同的是,數(shù)組索引不支持NOSORT和ONLINE用法。
數(shù)組索引使用
使用數(shù)組索引進(jìn)行查詢,必須使用謂詞CONTAINS。
語(yǔ)法格式
CONTAINS(< 索引列名>,)
或者
CONTAINS(< 索引列名>,arr_var_exp)
參數(shù)
val:必須為與對(duì)象列數(shù)組項(xiàng)相同或可轉(zhuǎn)換的標(biāo)量類(lèi)型表達(dá)式。
arr_var_exp:必須為數(shù)組類(lèi)型(DM靜態(tài)數(shù)組、動(dòng)態(tài)數(shù)組或者ORACLE兼容的嵌套表或VARRAY),其數(shù)組項(xiàng)類(lèi)型必須與對(duì)象列數(shù)組項(xiàng)類(lèi)型相同或可轉(zhuǎn)換。
舉例說(shuō)明
SQL> CREATE TYPE ARR_NUM1 IS VARRAY(1024) OF NUMBER; --VARRAY數(shù)組 2 / executed successfully used time: 17.012(ms). Execute id is 81. SQL> CREATE TYPE ARR_NUM2 IS TABLE OF NUMBER; --嵌套表 2 / executed successfully used time: 11.795(ms). Execute id is 82. SQL> CREATE TYPE ARR_NUM3 IS ARRAY NUMBER[]; --動(dòng)態(tài) 2 / executed successfully used time: 14.784(ms). Execute id is 83. SQL> CREATE TYPE ARR_NUM4 IS ARRAY NUMBER[3]; --靜態(tài) 2 / executed successfully used time: 14.017(ms). Execute id is 84. SQL> CREATE CLASS CLS1 AS V ARR_NUM1;END; 2 / executed successfully used time: 12.893(ms). Execute id is 85. SQL> CREATE TABLE TEST (C1 CLS1); executed successfully used time: 16.078(ms). Execute id is 87. SQL> INSERT INTO TEST VALUES(CLS1(ARR_NUM1(1,2,3))); affect rows 1 used time: 1.537(ms). Execute id is 88. SQL> INSERT INTO TEST VALUES(CLS1(ARR_NUM1(1,2))); affect rows 1 used time: 1.074(ms). Execute id is 89. SQL> INSERT INTO TEST VALUES(CLS1(ARR_NUM1(2,1))); affect rows 1 used time: 1.149(ms). Execute id is 90. SQL> INSERT INTO TEST VALUES(CLS1(ARR_NUM1(1,5))); affect rows 1 used time: 1.110(ms). Execute id is 91. SQL> INSERT INTO TEST VALUES(CLS1(ARR_NUM1(2,4))); affect rows 1 used time: 1.068(ms). Execute id is 92. SQL> INSERT INTO TEST VALUES(CLS1(ARR_NUM1(4,5,6))); affect rows 1 used time: 1.152(ms). Execute id is 93. SQL> commit; executed successfully used time: 17.231(ms). Execute id is 94. SQL> select * from test; LINEID C1 ---------- ------------------------ 1 JY.CLS1(ARR_NUM1(1,2,3)) 2 JY.CLS1(ARR_NUM1(1,2)) 3 JY.CLS1(ARR_NUM1(2,1)) 4 JY.CLS1(ARR_NUM1(1,5)) 5 JY.CLS1(ARR_NUM1(2,4)) 6 JY.CLS1(ARR_NUM1(4,5,6)) 6 rows got used time: 1.063(ms). Execute id is 95. SQL> CREATE ARRAY INDEX IDX ON TEST(C1); --創(chuàng)建數(shù)組索引 2 / executed successfully used time: 20.879(ms). Execute id is 97. SQL> SELECT * FROM TEST WHERE CONTAINS(C1,1,2,3); --使用數(shù)組索引查詢 2 / LINEID C1 ---------- ------------------------ 1 JY.CLS1(ARR_NUM1(1,2,3)) 2 JY.CLS1(ARR_NUM1(1,2)) 3 JY.CLS1(ARR_NUM1(2,1)) 4 JY.CLS1(ARR_NUM1(1,5)) 5 JY.CLS1(ARR_NUM1(2,4)) used time: 3.400(ms). Execute id is 98. SQL> --嵌套表 2 DECLARE 3 X ARR_NUM2; 4 BEGIN 5 X := ARR_NUM2(); 6 X.EXTEND(3); 7 X(1) := 1; 8 X(2) := 2; 9 X(3) := 3; 10 SELECT * FROM TEST WHERE CONTAINS(C1,X); 11 END; 12 / LINEID C1 ---------- ------------------------ 1 JY.CLS1(ARR_NUM1(1,2,3)) 2 JY.CLS1(ARR_NUM1(1,5)) 3 JY.CLS1(ARR_NUM1(2,1)) 4 JY.CLS1(ARR_NUM1(1,2)) 5 JY.CLS1(ARR_NUM1(2,4)) used time: 7.179(ms). Execute id is 100. SQL> --動(dòng)態(tài)數(shù)組 2 DECLARE 3 X ARR_NUM3; 4 BEGIN 5 X := NEW NUMBER [3]; 6 X[1]:= 1; 7 X[2]:= 2; 8 X[3]:= 3; 9 SELECT * FROM TEST WHERE CONTAINS(C1,X); 10 END; 11 / LINEID C1 ---------- ------------------------ 1 JY.CLS1(ARR_NUM1(1,2,3)) 2 JY.CLS1(ARR_NUM1(1,5)) 3 JY.CLS1(ARR_NUM1(2,1)) 4 JY.CLS1(ARR_NUM1(1,2)) 5 JY.CLS1(ARR_NUM1(2,4)) used time: 6.016(ms). Execute id is 102. SQL> --靜態(tài)數(shù)組 2 DECLARE 3 X ARR_NUM4; 4 BEGIN 5 X[1]:= 1; 6 X[2]:= 2; 7 X[3]:= 3; 8 SELECT * FROM TEST WHERE CONTAINS(C1,X); 9 END; 10 / LINEID C1 ---------- ------------------------ 1 JY.CLS1(ARR_NUM1(1,2,3)) 2 JY.CLS1(ARR_NUM1(1,5)) 3 JY.CLS1(ARR_NUM1(2,1)) 4 JY.CLS1(ARR_NUM1(1,2)) 5 JY.CLS1(ARR_NUM1(2,4)) used time: 5.688(ms). Execute id is 104.
數(shù)組索引刪除語(yǔ)句
數(shù)組索引刪除語(yǔ)句與普通索引用法相同
SQL> drop index idx; executed successfully used time: 402.153(ms). Execute id is 106. SQL> SELECT * FROM TEST WHERE CONTAINS(C1,1,2,3); SELECT * FROM TEST WHERE CONTAINS(C1,1,2,3); [-3252]:Error in line: 1 The array index is not created on the column[C1]. used time: 1.016(ms). Execute id is 0.
看完上述內(nèi)容,你們掌握DM7數(shù)組索引的概念是什么的方法了嗎?如果還想學(xué)到更多技能或想了解更多相關(guān)內(nèi)容,歡迎關(guān)注億速云行業(yè)資訊頻道,感謝各位的閱讀!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。