{"id":988,"date":"2012-07-06T23:44:02","date_gmt":"2012-07-06T15:44:02","guid":{"rendered":"https:\/\/yangtingkun.net\/?p=988"},"modified":"2012-07-11T23:48:59","modified_gmt":"2012-07-11T15:48:59","slug":"11gr2%e5%a2%9e%e5%bc%bacreate-or-replace-type%e5%8a%9f%e8%83%bd","status":"publish","type":"post","link":"https:\/\/yangtingkun.net\/?p=988","title":{"rendered":"11gr2\u589e\u5f3aCREATE OR REPLACE TYPE\u529f\u80fd"},"content":{"rendered":"<p>11.2\u5bf9\u4e8eCREATE OR REPLACE TYPE\u8bed\u53e5\u8fdb\u884c\u4e86\u589e\u52a0\uff0c\u589e\u52a0\u4e86FORCE\u9009\u9879\u3002<br \/>\n\u572811.2\u4e4b\u524d\uff0c\u53ea\u8981\u6709\u5176\u4ed6\u7684\u8868\u6216TYPE\u4f9d\u8d56\u4e86\u5f53\u524d\u5bf9\u8c61\uff0c\u8fd9\u4e2a\u5bf9\u8c61\u5c31\u65e0\u6cd5\u8fdb\u884cREPLACE\u4e86\uff1a<\/p>\n<pre lang='SQL'>SQL> create type t_num_tab is table of number;\r\n2 \/\r\nType created.\r\nSQL> create type t_record is object (id number, n_tab t_num_tab);\r\n2 \/\r\nType created.\r\nSQL> create or replace type t_num_tab is table of number(5);\r\n2 \/\r\ncreate or replace type t_num_tab is table of number(5);\r\n*\r\nERROR at line 1:\r\nORA-02303: cannot drop or replace a type with type or table dependents<\/pre>\n<p>\u8fd9\u662f11.2\u4e4b\u524d\u7684\u60c5\u51b5\uff0c\u5c1d\u8bd5\u6267\u884cCREATE OR REPLACE\u5c06\u4f1a\u5bfc\u81f4ORA-2303\u9519\u8bef\uff0c\u572811.2\u4e2dOracle\u589e\u52a0\u4e86FORCE\u529f\u80fd\uff0c\u4f7f\u5f97\u4e00\u4e2a\u4ec5\u88abTYPE\u6240\u4f9d\u8d56\u7684\u5bf9\u8c61\u4ecd\u7136\u53ef\u4ee5\u6267\u884cREPLACE\u7684\u64cd\u4f5c\uff1a<\/p>\n<pre lang='SQL'>SQL> create or replace type t_num_tab force is table of number(5);\r\n2 \/\r\nType created.\r\nSQL> select * from v$version;\r\nBANNER\r\n--------------------------------------------------------------------------------\r\nOracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production\r\nPL\/SQL Release 11.2.0.3.0 - Production\r\nCORE 11.2.0.3.0 Production\r\nTNS for Solaris: Version 11.2.0.3.0 - Production\r\nNLSRTL Version 11.2.0.3.0 - Production<\/pre>\n<p>\u6709\u610f\u601d\u7684\u662f\uff0cFORCE\u8bed\u53e5\u7684\u4f4d\u7f6e\u4e0d\u5bf9\u5219\u4e0d\u4f1a\u751f\u6548\uff0c\u8fd9\u65f6\u540c\u6837\u4f1a\u62a5ORA-2303\u7684\u9519\u8bef\uff0c\u800c\u5e76\u4e0d\u4f1a\u5bfc\u81f4\u8bed\u53e5\u9519\u8bef\uff1a<\/p>\n<pre lang='SQL'>SQL> create or replace force type t_num_tab is table of number(5);\r\ncreate or replace force type t_num_tab is table of number(5)\r\n*\r\nERROR at line 1:\r\nORA-02303: cannot drop or replace a type with type or table dependents\r\n\r\nSQL> create or replace type t_num_tab is table of number(5) force;\r\n2 \/\r\ncreate or replace type t_num_tab is table of number(5) force;\r\n*\r\nERROR at line 1:\r\nORA-02303: cannot drop or replace a type with type or table dependents<\/pre>\n<p>\u6700\u540e\u8fd9\u4e2a\u529f\u80fd\u53ea\u5bf9\u88abTYPE\u6240\u4f9d\u8d56\u7684\u5bf9\u8c61\u6709\u6548\uff0c\u4e00\u65e6\u5bf9\u8c61\u88ab\u8868\u6240\u4f9d\u8d56\uff0c\u5219FORCE\u529f\u80fd\u4e5f\u4e0d\u8d77\u4f5c\u7528\uff1a<\/p>\n<pre lang='SQL'>SQL> create table t_type_tab (id number, c_tab t_num_tab)\r\n2 nested table c_tab store as c_tab_tab;\r\nTable created.\r\nSQL> create or replace type t_num_tab force is table of number(6);\r\n2 \/\r\ncreate or replace type t_num_tab force is table of number(6);\r\n*\r\nERROR at line 1:\r\nORA-22866: cannot replace a type with table dependents<\/pre>\n<p>Oracle\u7684\u9519\u8bef\u4fe1\u606f\u4e5f\u53d8\u6210\u4e86ORA-22866\u3002\u5176\u5b9e\u8fd9\u65f6\u53ef\u4ee5\u9884\u6599\u7684\uff0c\u56e0\u4e3a\u4e00\u65e6\u521b\u5efa\u4e86\u8868\uff0c\u5c31\u76f8\u5f53\u4e8e\u8fdb\u884c\u4e86\u5b9e\u4f53\u5316\u7684\u5de5\u4f5c\uff0c\u5982\u679c\u4f9d\u8d56\u7684\u7c7b\u578b\u53d1\u751f\u4e86\u53d8\u5316\uff0c\u5c06\u4f1a\u5f71\u54cd\u8868\u4e2d\u5df2\u6709\u7684\u6570\u636e\u7684\u8bfb\u5199\u3002\u4e0d\u8fc7\u5176\u5b9eOracle\u53ef\u4ee5\u505a\u5230\u66f4\u8fdb\u4e00\u6b65\uff0c\u5c31\u662f\u5982\u679c\u8868\u6bb5\u6ca1\u6709\u521b\u5efa\u6216\u8005\u8868\u4e2d\u6ca1\u6709\u63d2\u5165\u6570\u636e\u7684\u60c5\u51b5\u4e0b\uff0c\u5141\u8bb8\u5bf9\u4f9d\u8d56\u7684\u5bf9\u8c61\u8fdb\u884c\u4fee\u6539\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>11.2\u5bf9\u4e8eCREATE OR REPLACE TYPE\u8bed\u53e5\u8fdb\u884c\u4e86\u589e\u52a0\uff0c\u589e\u52a0\u4e86FORCE\u9009\u9879\u3002 \u572811.2\u4e4b\u524d\uff0c\u53ea\u8981\u6709\u5176\u4ed6\u7684\u8868\u6216TYPE\u4f9d\u8d56\u4e86\u5f53\u524d\u5bf9\u8c61\uff0c\u8fd9\u4e2a\u5bf9\u8c61\u5c31\u65e0\u6cd5\u8fdb\u884cREPLACE\u4e86\uff1a SQL> create type t_num_tab is table of number; 2 \/ Type created. SQL> create type t_record is object (id number, n_tab t_num_tab); 2 \/ Type created. SQL> create or replace type t_num_tab is table of &hellip; <a href=\"https:\/\/yangtingkun.net\/?p=988\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3],"tags":[848,849,846,847,850],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p2yiY3-fW","_links":{"self":[{"href":"https:\/\/yangtingkun.net\/index.php?rest_route=\/wp\/v2\/posts\/988"}],"collection":[{"href":"https:\/\/yangtingkun.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yangtingkun.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yangtingkun.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/yangtingkun.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=988"}],"version-history":[{"count":1,"href":"https:\/\/yangtingkun.net\/index.php?rest_route=\/wp\/v2\/posts\/988\/revisions"}],"predecessor-version":[{"id":989,"href":"https:\/\/yangtingkun.net\/index.php?rest_route=\/wp\/v2\/posts\/988\/revisions\/989"}],"wp:attachment":[{"href":"https:\/\/yangtingkun.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=988"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yangtingkun.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=988"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yangtingkun.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=988"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}