對Oracle表分區的一點認識

來源:互聯網
上載者:User

Oracle的表資料分割函數通過改善可管理性、效能和可用性,從而為各式應用程式帶來了極大的好處。通常,分區可以使某些查詢以及維護操作的效能大大提高。此外,分區還可以極大簡化常見的管理工作,分區是構建千MB資料系統或超高可用性系統的關鍵工具。

資料分割函數能夠將表、索引或索引組織表進一步細分為段,這些資料庫物件的段叫做分區。每個分區有自己的名稱,還可以選擇自己的儲存特性。從資料庫管理員的角度來看,一個分區後的對象具有多個段,這些段既可進行集體管理,也可單獨管理,這就使資料庫管理員在管理分區後的對象時有相當大的靈活性。但是,從應用程式的角度來看,分區後的表與非分區表完全相同,使用 SQL DML 命令訪問分區後的表時,無需任何修改。

比較能理解的是以下幾個幾種表分區:

1 定界分割
每個分區都由一個分區索引值範圍指定create table RangeTable(
id int primary key,
name varchar(10),
grade int
)
partition by rang(grade)
(
partition part1 values less then(1000) tablespace Part1_tb,
partition part2 values less then(MAXVALUE) tablespace Part2_tb
);

2 列表分區
create table ListTable(
id int primary key,
name varchar(20),
area varchar(10)
)
partition by list(area)
(
partition part1 values('guangdong','beijing') tablespace Part1_tb,
partition part2 values('shanghai','nanjing') tablespace Part2_tb
);

3 散列分區
create table HashTable(
id int primary key,
name varchar(20),
grade int
)
partition by hash(grade)
partitions 10
store in(Part1_tb,Part2_tb,Part3_tb)
partition by rang(grade)(
partition part1 tablespace Part1_tb,
partition part2 tablespace Part2_tb
);

4 索引分割區
create index IndexTable_index
on IndexTable(name)
local
(
partition part1 tablespace Part1_tb,
partition part2 tablespace Part2_tb
)--local 告訴oracle表 IndexTable的每一個分區建立一個獨立的索引
create index IndexTable_index
on IndexTable(name)
global;
--global為全域索引 全域索引可以包含多個分區的值 局部索引比全域索引容易管理,而全域索引比較快
注意:不能為散列分區 或者 子分區建立全域索引。

聯繫我們

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