对Oracle表分区的一点认识
Jun 07, 2016 pm 04:59 PMOracle的表分区功能通过改善可管理性、性能和可用性,从而为各式应用程序带来了极大的好处。通常,分区可以使某些查询以及维护操
Oracle的表分区功能通过改善可管理性、性能和可用性,从而为各式应用程序带来了极大的好处。通常,分区可以使某些查询以及维护操作的性能大大提高。此外,分区还可以极大简化常见的管理任务,分区是构建千兆字节数据系统或超高可用性系统的关键工具。
分区功能能够将表、索引或索引组织表进一步细分为段,这些数据库对象的段叫做分区。每个分区有自己的名称,还可以选择自己的存储特性。从数据库管理员的角度来看,一个分区后的对象具有多个段,这些段既可进行集体管理,也可单独管理,这就使数据库管理员在管理分区后的对象时有相当大的灵活性。但是,从应用程序的角度来看,分区后的表与非分区表完全相同,使用 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为全局索引 全局索引可以包含多个分区的值 局部索引比全局索引容易管理,而全局索引比较快
注意:不能为散列分区 或者 子分区创建全局索引。

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Detailed tutorial on establishing a database connection using MySQLi in PHP

iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos

How does Go WebSocket integrate with databases?

Top 10 global digital currency trading apps recommended (2025 currency trading software ranking)

How to install and register the btc trading app?

How to handle database connections and operations using C++?

How to handle database connection errors in PHP

How to use database callback functions in Golang?
