Oracle 11g: 合并分區表-merge partition

來源:互聯網
上載者:User

Merging Partitions

使用ALTER TABLE .. MERGE PARTITION語句將兩個分區的內容合并到另外一個分區,兩個來源資料分割和關聯的local index都會被drop
  不能用於 hash分區表或 hash subpartitions of a composite *-hash partitioned table
  不能用於合并引用分區表(reference-partitioned table)
合并定界分割
  允許合并兩個臨近範圍的分區到另外分區,不相鄰分區無法合并。合并結果分區繼承兩個來源資料分割的最大邊界。
demo:

-- Create a Table with four partitions each on its own tablespace-- Partitioned by range on the data column.CREATE TABLE four_seasons(         one DATE,        two VARCHAR2(60),        three NUMBER)PARTITION  BY RANGE ( one ) (PARTITION quarter_one    VALUES LESS THAN ( TO_DATE('01-apr-1998','dd-mon-yyyy'))   TABLESPACE quarter_one,PARTITION quarter_two    VALUES LESS THAN ( TO_DATE('01-jul-1998','dd-mon-yyyy'))   TABLESPACE quarter_two,PARTITION quarter_three   VALUES LESS THAN ( TO_DATE('01-oct-1998','dd-mon-yyyy'))   TABLESPACE quarter_three,PARTITION quarter_four   VALUES LESS THAN ( TO_DATE('01-jan-1999','dd-mon-yyyy'))   TABLESPACE quarter_four);-- Create local PREFIXED index on Four_Seasons-- Prefixed because the leftmost columns of the index match the-- Partitioning key CREATE INDEX i_four_seasons_l ON four_seasons ( one,two ) LOCAL ( PARTITION i_quarter_one TABLESPACE i_quarter_one,PARTITION i_quarter_two TABLESPACE i_quarter_two,PARTITION i_quarter_three TABLESPACE i_quarter_three,PARTITION i_quarter_four TABLESPACE i_quarter_four);

下一步,合并分區.

-- Merge the first two partitions --ALTER TABLE four_seasons MERGE PARTITIONS quarter_one, quarter_two INTO PARTITION quarter_twoUPDATE INDEXES;

如果不顯式聲明 UPDATE INDEXES 語句,就必須給受影響的分區 rebuild the local index.

-- Rebuild index for quarter_two, which has been marked unusable -- because it has not had all of the data from Q1 added to it.-- Rebuilding the index will correct this.--ALTER TABLE four_seasons MODIFY PARTITION quarter_two REBUILD UNUSABLE LOCAL INDEXES;
合并Interval Partitions 

同RANGE一樣,必須兩個相鄰分區才能合并
合并 List partitions則沒有限制

相關文章

聯繫我們

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