查询嵌套表有哪些方法?

时间:2014-12-08 09:09:32

标签: sql oracle collections nested-table

我创建了一个嵌套表,现在我想以我知道的方式查询此表,即" select * from pOrder;"那么查询嵌套表的其他方法是什么?

CREATE TYPE typ_item AS OBJECT --create object
(prodid NUMBER(5),
price NUMBER(7,2) )

CREATE TYPE typ_item_nst -- define nested table type
AS TABLE OF typ_item;

CREATE TABLE pOrder ( -- create database table
ordid NUMBER(5),
supplier NUMBER(5),
requester NUMBER(4),
ordered DATE,
items typ_item_nst) -- here using the nested type column
NESTED TABLE items STORE AS item_stor_tab


INSERT INTO pOrder             --inserting a single value values
VALUES (800, 80, 8000, sysdate,
typ_item_nst (typ_item (88, 888)));

INSERT INTO pOrder -- i row holding multiple values means " a order id has many product"
VALUES (500, 50, 5000, sysdate, typ_item_nst(
typ_item(55, 555),
typ_item(56, 566),
typ_item(57, 577)));

1 个答案:

答案 0 :(得分:1)

试试这个

select t.ordid, t.supplier, t.requester, t.ordid, i.prodid, i.price
  from porder t, table(t.items) i

您可以在官方文档中阅读有关Table funciton的更多信息。