DM7數(shù)組索引的概念是什么,相信很多沒有經(jīng)驗的人對此束手無策,為此本文總結(jié)了問題出現(xiàn)的原因和解決方法,通過這篇文章希望你能解決這個問題。
公司主營業(yè)務(wù):成都做網(wǎng)站、成都網(wǎng)站設(shè)計、成都外貿(mào)網(wǎng)站建設(shè)、移動網(wǎng)站開發(fā)等業(yè)務(wù)。幫助企業(yè)客戶真正實現(xiàn)互聯(lián)網(wǎng)宣傳,提高企業(yè)的競爭能力。創(chuàng)新互聯(lián)建站是一支青春激揚(yáng)、勤奮敬業(yè)、活力青春激揚(yáng)、勤奮敬業(yè)、活力澎湃、和諧高效的團(tuán)隊。公司秉承以“開放、自由、嚴(yán)謹(jǐn)、自律”為核心的企業(yè)文化,感謝他們對我們的高要求,感謝他們從不同領(lǐng)域給我們帶來的挑戰(zhàn),讓我們激情的團(tuán)隊有機(jī)會用頭腦與智慧不斷的給客戶帶來驚喜。創(chuàng)新互聯(lián)建站推出自流井免費(fèi)做網(wǎng)站回饋大家。
數(shù)組索引指在一個只包含單個數(shù)組成員的對象列上創(chuàng)建的索引。
數(shù)組索引定義語句
語法格式
CREATE ARRAY INDEX < 索引名> ON [< 模式名>.] < 表名> (< 索引列定義>)
使用說明
1) 暫不支持在水平分區(qū)表上創(chuàng)建數(shù)組索引;
2) 暫時不支持在有數(shù)組索引表上進(jìn)行批量裝載(數(shù)組索引失效的例外);
3) 支持創(chuàng)建數(shù)組索引的對象只能包含數(shù)組一個成員。數(shù)組可以是DM靜態(tài)數(shù)組、動態(tài)數(shù)組或者ORACLE兼容的嵌套表或VARRAY;
4) 數(shù)組項類型只能是可比較的標(biāo)量類型,不支持復(fù)合類型、對象類型或大字段類型;
5) 臨時表、垂直分區(qū)表不支持;
6) 數(shù)組索引不支持改名;
7) 數(shù)組索引列不支持改名;
8) 數(shù)組索引只能是單索引,不能為組合索引;
9) 不支持空值的檢索
10) MPP環(huán)境不支持?jǐn)?shù)組索引。
數(shù)組索引修改語句
數(shù)組索引修改語句與普通索引用法相同,請參考3.7節(jié)。與普通索引不同的是,數(shù)組索引不支持NOSORT和ONLINE用法。
數(shù)組索引使用
使用數(shù)組索引進(jìn)行查詢,必須使用謂詞CONTAINS。
語法格式
CONTAINS(< 索引列名>,)
或者
CONTAINS(< 索引列名>,arr_var_exp)
參數(shù)
val:必須為與對象列數(shù)組項相同或可轉(zhuǎn)換的標(biāo)量類型表達(dá)式。
arr_var_exp:必須為數(shù)組類型(DM靜態(tài)數(shù)組、動態(tài)數(shù)組或者ORACLE兼容的嵌套表或VARRAY),其數(shù)組項類型必須與對象列數(shù)組項類型相同或可轉(zhuǎn)換。
舉例說明
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[]; --動態(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> --動態(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ù)組索引刪除語句
數(shù)組索引刪除語句與普通索引用法相同
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)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝各位的閱讀!