oracle交換分區方法以及注意事項

來源:互聯網
上載者:User

標籤:sele   建表   parallel   alt   寫法   csharp   entity   sys   sel   

1.查看該分區有無資料

select /*+ parallel(a 16) */ count(1) from ZJ2_GRIDLEVSTA_cell_ALL_571 partition(SYS_P16805) a --where  a.p_day=to_date(‘20171231‘,‘yyyymmdd‘);

2.如果分區表裡有主鍵,自增列,刪掉

alter table zj2_gridlevsta_all_571 drop primary key;drop index PK_ZJ2_GRIDLEVSTA_ALL_571_OID;alter table ZJ2_GRIDLEVSTA_CELL_ALL_571 modify oid drop identity;

3.建立表,保證索引,非空約束與分區表一致

create table ZJ2_GRIDLEVSTA_cell_ALL_571_b as select * from ZJ2_GRIDLEVSTA_cell_ALL_571 where 1=2;alter table ZJ2_GRIDLEVSTA_CELL_ALL_571_b modify oid not null;create index b_ECI_INDEX on ZJ2_GRIDLEVSTA_CELL_ALL_571_b (ECI);

4.分區表和非分區表 交換分區

alter table ZJ2_GRIDLEVSTA_cell_ALL_571 exchange partition  SYS_P16805  with table ZJ2_GRIDLEVSTA_cell_ALL_571_b;

  

注意:要交換的分區表中不能含有自增列,主鍵,否則可能無法交換分區

 

 

select /*+ parallel(a 16) */ count(1) from 這種寫法是可以多進程同時查看資料,效率要比普通查看效果快的多,但不可在程式中這樣寫,因為它會獨佔進程,多人同時查看的話會比普通方法
還要慢。

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.