SQL> SQL> -- XMLType view is similar to object view SQL> -- This is a non-schema-based XMLType view SQL> SQL> desc emp Name Null? Type ----------------------------------------- -------- ---------------------------- EMPNO NOT NULL NUMBER(4) ENAME VARCHAR2(10) JOB VARCHAR2(9) MGR NUMBER(4) HIREDATE DATE SAL NUMBER(7,2) COMM NUMBER(7,2) DEPTNO NUMBER(2) SQL> SQL> CREATE OR REPLACE VIEW Emp_view OF XMLTYPE WITH OBJECT ID 2 (EXTRACT(sys_nc_rowinfo$,'/Emp/@empno').getnumberval()) 3 AS SELECT XMLELEMENT("Emp", XMLAttributes(empno), 4 XMLForest(e.ename AS "name", 5 e.hiredate AS "hiredate")) AS "result" 6 FROM emp e 7 WHERE sal > 3000; View created. SQL> SQL> desc emp_view Name Null? Type ----------------------------------------- -------- ---------------------------- TABLE of SYS.XMLTYPE SQL> -- Each row of an XMLType view corresponds to an XMLType instance SQL> -- empno attribute in the document should become the unique identifier for each row. SQL> -- SYS_NC_ROWINFO$ is a virtual column that references the row XMLType instance. SQL> select * from emp_view; SYS_NC_ROWINFO$ -------------------------------------------------------------------------------- KING 17-NOV-81 DAVID 01-JAN-01 jusung 01-JAN-03 JOHN 01-JAN-01 SQL> SQL> -- What's TYPE_TEXT_LENGTH? SQL> -- Length of the type clause of the typed view. SQL> -- Add and remove spaces behind 'XMLTYPE' in the view creation SQL and see what happens. SQL> -- It does not mean much SQL> select * from user_views where view_name='EMP_VIEW'; VIEW_NAME TEXT_LENGTH ------------------------------ ----------- TEXT -------------------------------------------------------------------------------- TYPE_TEXT_LENGTH ---------------- TYPE_TEXT -------------------------------------------------------------------------------- OID_TEXT_LENGTH --------------- OID_TEXT -------------------------------------------------------------------------------- VIEW_TYPE_OWNER VIEW_TYPE ------------------------------ ------------------------------ SUPERVIEW_NAME ------------------------------ EMP_VIEW 197 SELECT XMLELEMENT("Emp", XMLAttributes(empno), XMLForest(e.ename AS "name", e.hiredate AS "hiredate")) AS "result" FROM emp e WHERE sal > 3000 8 XMLTYPE 53 EXTRACT(sys_nc_rowinfo$,'/Emp/@empno').getnumberval() SYS XMLTYPE SQL> SQL> spool off