Oracle PL/SQL之巢狀表格(Nested Table)

來源:互聯網
上載者:User

Test Code:

Connected to Oracle Database 11g Enterprise Edition Release 11.1.0.7.0<br />Connected as xxpo</p><p>SQL> CREATE OR REPLACE TYPE color_tab_t AS TABLE OF VARCHAR2(30);<br /> 2 /</p><p>Type created</p><p>SQL><br />SQL> CREATE TABLE color_models (<br /> 2 model_type VARCHAR2(12)<br /> 3 , colors color_tab_t<br /> 4 )<br /> 5 NESTED TABLE colors STORE AS color_model_colors_tab<br /> 6 /</p><p>Table created</p><p>SQL><br />SQL> BEGIN<br /> 2 INSERT INTO color_models<br /> 3 VALUES ('RGB', color_tab_t ('RED','GREEN','BLUE'));<br /> 4 END;<br /> 5 /</p><p>PL/SQL procedure successfully completed</p><p>SQL> select * from color_models;</p><p>MODEL_TYPE COLORS<br />------------ ------<br />RGB <Objec</p><p>SQL> select * from color_model_colors_tab;</p><p>select * from color_model_colors_tab</p><p>ORA-22812: cannot reference nested table column's storage table</p><p>SQL><br />SQL> SELECT object_name<br /> 2 ,object_type<br /> 3 ,status<br /> 4 FROM dba_objects<br /> 5 WHERE object_name = upper('COLOR_MODEL_COLORS_TAB');</p><p>OBJECT_NAME OBJECT_TYPE STATUS<br />-------------------------------------------------------------------------------- ------------------- -------<br />COLOR_MODEL_COLORS_TAB TABLE VALID</p><p>SQL> SELECT /*+NESTED_TABLE_GET_REFS+*/ * FROM COLOR_MODEL_COLORS_TAB;</p><p>COLUMN_VALUE<br />------------------------------<br />RED<br />GREEN<br />BLUE</p><p>SQL>

 

Ref:

1. Page 357, Oracle PL/SQL Programming FIFTH EDITION, Steven Feuerstein with Bill Pribyl, O'REILLY

2. http://www.itpub.net/viewthread.php?tid=640129

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.