DM7 陣列索引
陣列索引指在一個只包含單個陣列成員的物件列上建立的索引。
陣列索引定義語句
語法格式
CREATE ARRAY INDEX < 索引名> ON [< 模式名>.] < 表名> (< 索引列定義>)
使用說明
1) 暫不支援在水平分割槽表上建立陣列索引;
2) 暫時不支援在有陣列索引表上進行批次裝載(陣列索引失效的例外);
3) 支援建立陣列索引的物件只能包含陣列一個成員。陣列可以是DM靜態陣列、動態陣列或者ORACLE相容的巢狀表或VARRAY;
4) 陣列項型別只能是可比較的標量型別,不支援複合型別、物件型別或大欄位型別;
5) 臨時表、垂直分割槽表不支援;
6) 陣列索引不支援改名;
7) 陣列索引列不支援改名;
8) 陣列索引只能是單索引,不能為組合索引;
9) 不支援空值的檢索
10) MPP環境不支援陣列索引。
陣列索引修改語句
陣列索引修改語句與普通索引用法相同,請參考3.7節。與普通索引不同的是,陣列索引不支援NOSORT和ONLINE用法。
陣列索引使用
使用陣列索引進行查詢,必須使用謂詞CONTAINS。
語法格式
CONTAINS(< 索引列名>,)
或者
CONTAINS(< 索引列名>,arr_var_exp)
引數
val:必須為與物件列陣列項相同或可轉換的標量型別表示式。
arr_var_exp:必須為陣列型別(DM靜態陣列、動態陣列或者ORACLE相容的巢狀表或VARRAY),其陣列項型別必須與物件列陣列項型別相同或可轉換。
舉例說明
SQL> CREATE TYPE ARR_NUM1 IS VARRAY(1024) OF NUMBER; --VARRAY陣列 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[]; --動態 2 / executed successfully used time: 14.784(ms). Execute id is 83. SQL> CREATE TYPE ARR_NUM4 IS ARRAY NUMBER[3]; --靜態 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); --建立陣列索引 2 / executed successfully used time: 20.879(ms). Execute id is 97. SQL> SELECT * FROM TEST WHERE CONTAINS(C1,1,2,3); --使用陣列索引查詢 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> --動態陣列 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> --靜態陣列 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.
陣列索引刪除語句
陣列索引刪除語句與普通索引用法相同
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.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26015009/viewspace-2676121/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 尋找陣列的中心索引陣列索引
- DM8管理陣列索引陣列索引
- JavaScript 陣列 指定索引位置插入元素JavaScript陣列索引
- 第六篇 numpy陣列索引陣列索引
- 如何在 bash 中使用索引陣列索引陣列
- 易語言陣列 ,索引從 1 開始。陣列索引
- 【C#】山脈陣列的峰頂索引C#陣列索引
- 【numpy學習筆記】陣列的切片,索引,迭代筆記陣列索引
- C#快速入門教程(19)—— 索引器與陣列C#索引陣列
- NumPy 陣列建立方法與索引訪問詳解陣列索引
- LeetCode每日一題:找陣列的中心索引(No.724)LeetCode每日一題陣列索引
- 數學建模例題2.27 陣列元素的索引示例陣列索引
- js如何使用索引訪問陣列物件中的元素JS索引陣列物件
- JavaSE 陣列:一維陣列&二維陣列Java陣列
- 陣列,陣列類,SyStem類陣列
- Java陣列03:陣列使用Java陣列
- 索引與null(一):單列索引索引Null
- 陣列--移除陣列中指定的元素,不改變原陣列和改變原陣列陣列
- 陣列二:使用陣列可變函式為陣列排序陣列函式排序
- 指標陣列和陣列指標與二維陣列指標陣列
- 陣列指標,指標陣列陣列指標
- Javascript - 陣列和陣列的方法JavaScript陣列
- MySQL 生成列索引MySql索引
- 記一次陣列操作:陣列 A 根據陣列 B 排序陣列排序
- [求解]陣列,分成倆個陣列,陣列值之和的相差最小。陣列
- 陣列陣列
- MySQL通過通用列索引來提供一個JSON列索引MySql索引JSON
- 矩陣和陣列矩陣陣列
- iOS 字典轉陣列,陣列轉字典iOS陣列
- PHP陣列轉換為js陣列PHP陣列JS
- 【陣列】977. 有序陣列的平方陣列
- 指標陣列與陣列指標指標陣列
- 2-7 陣列:動態陣列陣列
- 陣列演算法-差分陣列陣列演算法
- scala陣列與java陣列對比陣列Java
- FCC-JS-BAS-Where do I belong-陣列排序並找出元素索引JS陣列排序索引
- 稀疏陣列、佇列陣列佇列
- 點陣圖索引(轉載)索引