--表分区需要在创建表的时候创建
--1.范围分区(最后一个区必须有最大值限制maxvlaue表示大于3000的所有值)
create table comp(
id number(10) primary key,
name varchar2(50) not null,
price number(10,2) not null
)
partition by range(price)(
partition p1 values less than(1000),
partition p2 values less than(2000),
partition p3 values less than(3000),
partition p4 values less than(maxvalue),
)
--2.散列分区(通过在分区键上执行HASH函数决定存储的分区)
create table emp(
empId number(8) not null,
empName varchar2(30) not null,
address varchar2(50),
departmentId number(5) /*部门编号*/
)
partition by hash(departmentId) partitions 5;
--3.列表分区(允许用户将不相关的数据组织在一起)
create table emp(
empId number(8) not null,
empName varchar2(30) not null,
address varchar2(50),
departmentId number(5) /*部门编号*/
)
partition by list(address) (
partition p1 values('上海'),
partition p2 values('北京'),
partition p3 values('深圳','广州'),
partition p4 values(default)
);
--4.复合分区(范围分区与散列分区或列表分区的组合)
create table comp(
productId number(10) not null,
sale_date date not null,/*销售日期*/
sale_cost number(15) /*销售成本*/
)
partition by range(sale_date) //范围分区
subpartition by hash(productId) subpartitions 5 //散列分区
(
//范围分区
partition p1 values less than (to_date('2001-1-1','YYYY-MM-DD')),
partition p2 values less than (to_date('2002-1-1','YYYY-MM-DD')),
partition p3 values less than (maxvalue)
);
创建表分区(提高性能重要手段)
猜你喜欢
转载自blog.csdn.net/u013938578/article/details/81411664
今日推荐
周排行