你需要使用表(t.collection_field)
看到鏈接Unnesting Results of Collection Queries
例子以上:
SELECT e.*
FROM department_persons d, TABLE(d.dept_emps) e;
IDNO NAME PHONE
---------- ------------------------------ ---------------
1 John Smith 1-650-555-0135
2 Diane Smith 1-650-555-0135
從上方
鏈路擴展樣本
CREATE TYPE person_typ AS OBJECT (
idno NUMBER,
name VARCHAR2(30),
phone VARCHAR2(20),
MAP MEMBER FUNCTION get_idno RETURN NUMBER,
MEMBER PROCEDURE display_details (SELF IN OUT NOCOPY person_typ));
CREATE TYPE BODY person_typ AS
MAP MEMBER FUNCTION get_idno RETURN NUMBER IS
BEGIN
RETURN idno;
END;
MEMBER PROCEDURE display_details (SELF IN OUT NOCOPY person_typ) IS
BEGIN
-- use the put_line procedure of the DBMS_OUTPUT package to display details
DBMS_OUTPUT.put_line(TO_CHAR(idno) || ' - ' || name || ' - ' || phone);
END;
END;
CREATE TYPE people_typ AS TABLE OF person_typ; -- nested table type
CREATE TABLE department_persons (
dept_no NUMBER PRIMARY KEY,
dept_name CHAR(20),
dept_mgr person_typ DEFAULT person_typ(10,'John Doe',NULL),
dept_emps people_typ DEFAULT people_typ()) -- instance of nested table type
NESTED TABLE dept_emps STORE AS dept_emps_tab;
INSERT INTO department_persons VALUES
(101, 'Physical Sciences', person_typ(65,'Vrinda Mills', '1-650-555-0125'),
people_typ(person_typ(1, 'John Smith', '1-650-555-0135'),
person_typ(2, 'Diane Smith', NULL)));
INSERT INTO department_persons VALUES
(104, 'Life Sciences', person_typ(70,'James Hall', '1-415-555-0101'),
people_typ()); -- an empty people_typ table
select * from department_persons
回報收藏在你的描述
DEPT_NO DEPT_NAME DEPT_MGR.IDNO DEPT_MGR.NAME DEPT_MGR.PHONE DEPT_EMPS
1 101 Physical Sciences 65 Vrinda Mills 1-650-555-0125 <Collection>
2 104 Life Sciences 70 James Hall 1-415-555-0101 <Collection>
如果添加表你有你需要什麼
SELECT e.*
FROM department_persons d, TABLE(d.dept_emps) e;
IDNO NAME PHONE
1 1 John Smith 1-650-555-0135
2 2 Diane Smith
來源
2015-11-13 21:12:13
are