Oracle表分區

來源:互聯網
上載者:User

標籤:lte   rac   速度   update   div   ros   使用   range   char   

  當資料非常龐大的時候,比如,要查詢ID<1000的時候,如果不使用表分區的話,需要全表掃描(判斷每條記錄的ID是否小於1000),這樣大大影響了查詢的速度。建立索引是效能調優的方法,同樣,表分區也是。每個分區都是獨立的一個段,可以放在不同的資料表空間下面。

  表分區有以下優點:

  (1)由於將資料分散到各個區中,減少了資料損毀的可能性。

  (2)可以對單獨的分區進行資料的備份與恢複。

  (3)可以將分區分散到不同的物理磁碟,來分散IO。

  (4)提高資料庫管理與效能。

  oracle提供了以下幾種分區方法:

  (1)定界分割(range)  (2)雜湊分割(hash)   (3)列表分區(List) (4)範圍-雜湊分割   (5)範圍-列表分區

  range分區:就是根據表的某個欄位值範圍進行分區。 如下:建立分區表,根據ID的值進行分區,如果某些值暫時無法預測,可以使用maxvalue。

create table testpartition(id number,name varchar(100)) partition by range(id)(       partition p1 values less than (10),       partition p2 values less than (20),       partition p3 values less than (30),       partition p4 values less than (maxvalue))

  查看使用者表分區情況:

select * from user_tab_partitions

  

  插入資料:

insert into testpartition values(15,‘zhengxisheng‘)insert into testpartition values(5,‘jisheng‘)insert into testpartition values(32,‘jidong‘)

  查詢各個分區的資料:

select * from testpartition partition(p2)

  

  更新資料:報錯如下:

update testpartition set id =‘12‘ where  id =‘5‘

  

  需要成設定可移動的分區:

alter table testpartition enable row movementupdate testpartition set id =‘12‘ where  id =‘5‘

  重新查詢分區p2的資料:

  

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.