{"id":1040,"date":"2012-07-22T23:40:46","date_gmt":"2012-07-22T15:40:46","guid":{"rendered":"https:\/\/yangtingkun.net\/?p=1040"},"modified":"2012-08-05T15:11:41","modified_gmt":"2012-08-05T07:11:41","slug":"%e5%88%86%e5%8c%ba%e8%a1%a8unused%e5%88%97%e5%90%8e%e7%9a%84exchange-partition%e6%93%8d%e4%bd%9c","status":"publish","type":"post","link":"https:\/\/yangtingkun.net\/?p=1040","title":{"rendered":"\u5206\u533a\u8868UNUSED\u5217\u540e\u7684EXCHANGE PARTITION\u64cd\u4f5c"},"content":{"rendered":"<p>\u78b0\u5230\u4e00\u4e2a\u6709\u610f\u601d\u7684\u95ee\u9898\uff0c\u5982\u679c\u5206\u533a\u8868\u6267\u884c\u8fc7SET UNUSED\u64cd\u4f5c\uff0c\u90a3\u4e48\u662f\u5426\u8fd8\u53ef\u4ee5\u8fdb\u884c\u5206\u533a\u7684EXCHANGE\u64cd\u4f5c\u3002<br \/>\n\u4e00\u4e2a\u7b80\u5355\u7684\u6d4b\u8bd5\u5c31\u53ef\u4ee5\u8bf4\u660e\u8fd9\u4e2a\u95ee\u9898\uff1a<\/p>\n<pre lang='SQL'>SQL> create table t_part_unused \r\n  2  (id number, name varchar2(30), other varchar2(30))\r\n  3  partition by range (id) \r\n  4  (partition p1 values less than (10), \r\n  5  partition pmax values less than (maxvalue));\r\nTable created.\r\nSQL> insert into t_part_unused \r\n  2  select rownum, table_name, 'abc' \r\n  3  from user_tables;\r\n48 rows created.\r\nSQL> commit;\r\nCommit complete.\r\nSQL> alter table t_part_unused set unused (other);\r\nTable altered.\r\nSQL> desc t_part_unused\r\n Name                                     Null?    Type\r\n ---------------------------------------- -------- ------------------------\r\n ID                                                NUMBER\r\n NAME                                              VARCHAR2(30)\r\nSQL> create table t_temp_unused as\r\n  2  select * \r\n  3  from t_part_unused\r\n  4  where 1 = 2;\r\nTable created.\r\nSQL> desc t_temp_unused\r\n Name                                     Null?    Type\r\n ---------------------------------------- -------- ------------------------\r\n ID                                                NUMBER\r\n NAME                                              VARCHAR2(30)\r\nSQL> alter table t_part_unused\r\n  2  exchange partition p1\r\n  3  with table t_temp_unused;\r\nwith table t_temp_unused\r\n           *\r\nERROR at line 3:\r\nORA-14097: column type or size mismatch in ALTER TABLE EXCHANGE PARTITION\r\n\r\nSQL> alter table t_temp_unused add (other varchar2(30));\r\nTable altered.\r\nSQL> alter table t_part_unused\r\n  2  exchange partition p1\r\n  3  with table t_temp_unused;\r\nwith table t_temp_unused\r\n           *\r\nERROR at line 3:\r\nORA-14096: tables in ALTER TABLE EXCHANGE PARTITION must have the same number of columns\r\n\r\nSQL> alter table t_temp_unused set unused (other);\r\nTable altered.\r\nSQL> alter table t_part_unused\r\n  2  exchange partition p1\r\n  3  with table t_temp_unused;\r\nTable altered.<\/pre>\n<p>\u5f88\u660e\u663e\u6267\u884c\u4e86SET UNUSED\u64cd\u4f5c\u540e\u7684\u8868\uff0c\u548c\u666e\u901a\u7684\u8868\u662f\u5b58\u5728\u533a\u522b\u7684\uff0c\u8fd9\u79cd\u533a\u522b\u5bfc\u81f4\u8981\u6c42\u8fdb\u884cEXCHANGE\u7684\u8868\u5fc5\u987b\u540c\u6837\u6267\u884cSET UNUSED\u64cd\u4f5c\uff0c\u5426\u5219\u5c31\u65e0\u6cd5\u6267\u884cEXCHANGE\u7684\u64cd\u4f5c\u3002<br \/>\n\u5f53\u76ee\u6807\u8868\u4e2d\u4e0d\u5305\u542bSETE UNUSED\u7684\u5217\u65f6\uff0cEXCHANGE\u64cd\u4f5c\u4f1a\u51fa\u73b0ORA-14097\u7684\u9519\u8bef\uff0c\u800c\u5982\u679c\u628a\u5217\u6dfb\u52a0\u5230\u76ee\u6807\u8868\uff0c\u5219\u4f1a\u62a5\u9519ORA-14096\uff0c\u5fc5\u987b\u5728\u76ee\u6807\u8868\u540c\u6837\u5bf9\u5217\u6267\u884cSET UNUSED\u64cd\u4f5c\uff0c\u624d\u80fd\u901a\u8fc7EXCHANGE\u4e4b\u524d\u7684\u68c0\u67e5\u3002<br \/>\n\u5176\u5b9e\u8fd9\u4e5f\u4e0d\u96be\u7406\u89e3\uff0c\u6267\u884cSET UNUSED\u547d\u4ee4\u540e\uff0c\u6570\u636e\u5b57\u5178\u867d\u7136\u53d1\u751f\u4e86\u6539\u53d8\uff0c\u4f46\u662f\u8868\u4e0a\u7684\u6570\u636e\u5e76\u6ca1\u6709\u5220\u9664\uff0c\u800cEXCHANGE\u64cd\u4f5c\u53ea\u662f\u5c06\u4e24\u4e2a\u6bb5\u7684\u6570\u636e\u5b57\u5178\u8fdb\u884c\u4e92\u6362\uff0c\u56e0\u6b64\u5982\u679c\u76ee\u6807\u8868\u4e0a\u7f3a\u5c11SET UNUSED\u5217\uff0c\u662f\u65e0\u6cd5\u6267\u884cEXCHANGE\u64cd\u4f5c\u7684\u3002<br \/>\n\u89e3\u51b3\u95ee\u9898\u7684\u65b9\u6cd5\u6709\u4e24\u4e2a\uff0c\u7b2c\u4e00\u4e2a\u5c31\u662f\u4f8b\u5b50\u4e2d\u5c55\u793a\u7684\u53ef\u4ee5\u5728\u76ee\u6807\u8868\u4e0a\u5efa\u7acb\u5217\u7136\u540e\u540c\u6837\u7684\u6267\u884cSET UNUSED\u64cd\u4f5c\uff1b\u53e6\u5916\u7684\u4e00\u4e2a\u65b9\u6cd5\u5c31\u662f\u5bf9\u4e8eSET UNUSED\u5217\u6267\u884cDROP COLUMN\u64cd\u4f5c\uff0c\u5f7b\u5e95\u5220\u9664\u8be5\u5217\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u78b0\u5230\u4e00\u4e2a\u6709\u610f\u601d\u7684\u95ee\u9898\uff0c\u5982\u679c\u5206\u533a\u8868\u6267\u884c\u8fc7SET UNUSED\u64cd\u4f5c\uff0c\u90a3\u4e48\u662f\u5426\u8fd8\u53ef\u4ee5\u8fdb\u884c\u5206\u533a\u7684EXCHANGE\u64cd\u4f5c\u3002 \u4e00\u4e2a\u7b80\u5355\u7684\u6d4b\u8bd5\u5c31\u53ef\u4ee5\u8bf4\u660e\u8fd9\u4e2a\u95ee\u9898\uff1a SQL> create table t_part_unused 2 (id number, name varchar2(30), other varchar2(30)) 3 partition by range (id) 4 (partition p1 values less than (10), 5 partition pmax values less than (maxvalue)); Table created. SQL> insert into t_part_unused 2 &hellip; <a href=\"https:\/\/yangtingkun.net\/?p=1040\">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":[894,893,461,891,890,460,892],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p2yiY3-gM","_links":{"self":[{"href":"https:\/\/yangtingkun.net\/index.php?rest_route=\/wp\/v2\/posts\/1040"}],"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=1040"}],"version-history":[{"count":1,"href":"https:\/\/yangtingkun.net\/index.php?rest_route=\/wp\/v2\/posts\/1040\/revisions"}],"predecessor-version":[{"id":1042,"href":"https:\/\/yangtingkun.net\/index.php?rest_route=\/wp\/v2\/posts\/1040\/revisions\/1042"}],"wp:attachment":[{"href":"https:\/\/yangtingkun.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1040"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yangtingkun.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1040"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yangtingkun.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1040"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}