create or replace type NUMBER_ARR is table of NUMBER;
/
create or replace TYPE ARRAY2D AS TABLE OF NUMBER_ARR;
/
create table t (id integer primary key, n array2d)
nested table n store as n_a(nested table column_value store as n_c);
insert into t values(1, array2d(number_arr(1,2), number_arr(3,4)));
insert into t values(2, array2d(number_arr(1,4)));
Select * from t
显示:
ID N
----------------------------
1 [unsupported data type]
2 [unsupported data type]
现在,显示值,你必须每个元素转换成表格,并加入像这样:
select t1.id, t3.column_value value
from t t1, table(t1.column_value) t2, table(t2.column_value) t3;
ID value
----------------
1 1
1 2
1 3
1 4
2 1
2 4
显示每个所有值ID,您可以使用listagg
select t1.id,
listagg(t3.column_value, ', ')
within group (order by t3.column_value) value
from t t1, table(t1.column_value) t2, table(t2.column_value) t3
group by t1.id;
ID value
----------------
1 1, 2, 3, 4
2 1, 4
Ofcourse,它将2d数组的所有元素显示为单个数字串。 正确的显示(即自己的括号像((1,2,3,4),(4,5,6)))
内的每个阵列是不可能的,因为根据你的当前类型定义
这不起作用:
select id, '(' || listagg(value, ',')
within group (order by value) || ')' from
(select t1.id, t2.column_value c, '(' || listagg(t3.column_value, ',')
within group (order by t3.column_value) ||')' value
from t t1, table(t1.column_value) t2, table(t2.column_value) t3
group by t1.id, c)
group by id;
为了让像上述工作的查询,你有定义对象类型和定义map and order functions。
最后,我想说的是,你应该定期的数据类型为坚持他们更加高效。
P.S. - 如果没有唯一的密钥,则必须使用rownum
或rowid
。
你的代码在哪里,你可以看到行的东西,看不到的元素。 '元素的类型被列为不透明.'你在哪里看到它? “我为整张桌子准备了这张桌子的DDL。需要更详细的信息。接下来为什么要编译集合数据类型以进行调试? –
http://prntscr.com/dogcei – Kristjan
http://prntscr.com/dogcei http://prntscr.com/dogcle http://prntscr.com/dogctc http://prntscr.com/dogcxk 正如你可以看到最后一张图片我不能看到数组中的值。它的类型是不透明的。在我编译集合数据类型之前,我甚至不能“查看表”。它说类型:不透明的第一张图片allready(现在是array2d)。 我希望我现在更清楚一点。 – Kristjan