Oracle 線上擴充分區

來源:互聯網
上載者:User

標籤:style   color   io   os   ar   strong   for   2014   art   

    在對分區表操作是,當一個分區已經有了最大的分區,如何再次擴充分區呢?簡單的方式是先刪除最大分區,然後添加需要的分區,再次建立最大分區,如果對於7*24小時的系統,可能不行。哪有什麼辦法呢?下面來做個實驗:

SQL> select * from v$version;
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi
PL/SQL Release 10.2.0.1.0 - Production
CORE    10.2.0.1.0      Production
TNS for 64-bit Windows: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production

SQL> drop table test purge;

SQL> create table test
   (
     id number,
     record_date date
   )partition by range(record_date)
   (
     partition p_2013 values less than(to_date(‘2013-01-01‘,‘yyyy-MM-dd‘)),
     partition p_2014 values less than(to_date(‘2014-01-01‘,‘yyyy-MM-dd‘)),
     partition p_max values less than (maxvalue)
   );

SQL> insert into test values(1,to_date(‘2012-10-01‘,‘yyyy-MM-dd‘));
SQL> insert into test values(2,to_date(‘2013-10-01‘,‘yyyy-MM-dd‘));
SQL> insert into test values(3,to_date(‘2014-10-01‘,‘yyyy-MM-dd‘));
SQL> commit;
SQL> select partition_name from user_tab_partitions
     where table_name = ‘TEST‘
     order by partition_position;
PARTITION_NAME
------------------------------
P_2013
P_2014
P_MAX

SQL> select * from test partition(p_2013);
        ID RECORD_DATE
---------- --------------
         1 01-10月-12

SQL> select * from test partition(p_2014);
        ID RECORD_DATE
---------- --------------
         2 01-10月-13

SQL> select * from test partition(p_max);
        ID RECORD_DATE
---------- --------------
         3 01-10月-14

SQL> alter table test add partition p_2015 values
           less than(to_date(‘2015-10-01‘,‘yyyy-MM-dd‘));
alter table test add partition p_2015 values
                               *
第 1 行出現錯誤:
ORA-14074: 分區界限必須調整為高於最後一個分區界限

SQL> alter table test split partition p_max at (to_date(‘2015-01-01‘,‘yyyy-MM-dd‘))
      into (partition p_2015, partition p_max)  update global indexes;

SQL> select partition_name from user_tab_partitions
     where table_name = ‘TEST‘
     order by partition_position;
PARTITION_NAME
------------------------------
P_2013
P_2014
P_2015
P_MAX

SQL> insert into test values(4,to_date(‘2015-10-01‘,‘yyyy-MM-dd‘));
SQL> commit;
SQL> select * from test partition(p_2015);
        ID RECORD_DATE
---------- --------------
         3 01-10月-14
         
SQL> select * from test partition(p_max);
        ID RECORD_DATE
---------- --------------
         4 01-10月-15

Oracle 線上擴充分區

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.