Oracle SQL: select from table with nested table

若如初见. 提交于 2019-12-30 08:35:09

问题


I wonder how can i make select statement from table which have a typed column ? Type of this column is defined as:

create or replace TYPE "MYCOL" as table of MYTYPE; 
create or replace TYPE "MYTYPE" as OBJECT
( myid Number, myname Varchar2);

UPD1 Table is defined as

CREATE TABLE "T_TABLE" 
   (    "ID" NUMBER NOT NULL ENABLE, "NAME" "MYCOL" )

If i select this column with select * from T_TABLE i will get this not informative result:

1, MYSCHEMA.MYCOL([MYSCHEMA.MYTYPE],[MYSCHEMA.MYTYPE])

I want just to unwrap this types.


回答1:


Try it like this:

select t."ID", tt.myid, tt.myname 
from "T_TABLE" t, table(t."NAME") tt;

Here is a sqlfiddle demo



来源:https://stackoverflow.com/questions/13972198/oracle-sql-select-from-table-with-nested-table

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!