分区表和分区索引

创建分区表

1.范围分区
create table student_range(
        sno number(6) primary key,
        sname varchar2(10),
        sage int,
        birthday date
)
partition by range(birthday)
(
        partition p1 values less than
                (to_date('1980-1-1','YYYY-MM-DD')) tablespace orcltbs1,
        partition p2 values less than
                (to_date('1990-1-1','YYYY-MM-DD')) tablespace orcltbs2,
        partition p3 values less than(maxvalue)
                tablespace orcltbs3 storage(initial 10M next 20M)
)
storage(initial 1M next 1M maxextents 10);
2.列表分区
create table student_list(
        sno number(6) primary key,
        sname varchar2(10),
        sex char(2) check(sex in ('M','F'))
)
partition by list(sex)
(
        partition student_male values('M') tablespace orcltbs1,
        partition student_female values('F') tablespace orcltbs2
);

3.散列分区

create table student_hash(
        sno number(6) primary key,
        sname varchar2(10)
)
partition by hash(sno)
(
        partition p1 tablespace orcltbs1,
        partition p2 tablespace orcltbs2
);

或者按照分区的数量分区

create table stadent_hash1(
        sno number(6) primary key,
        sname varchar2(10)
)
partition by hash(sno)
partitions 2 store in (orcltbs1,orcltbs2);
~

4.复合分区
范围-列表复合分区

create table student_range_list(
        sno number(6) primary key,
        sname varchar2(10),
        sex char(2) check(sex IN ('M','F')),
        sage number(4),
        birthday date
)
partition by range(birthday)
  subpartition by list(sex)
(       
        partition p1 values less than(to_date('1980-1-1','YYYY-MM-DD'))
                (
                subpartition p1_sub1 values('M') tablespace orcltbs1,
                subpartition p1_sub2 values('F') tablespace orcltbs2
                ),
        partition p2 values less than(to_date('1990-1-1','YYYY-MM-DD'))
                (
                subpartition p2_sub1 values('M') tablespace orcltbs3,
                subpartition p2_sub2 values('F') tablespace orcltbs4
                ),
        partition p3 values less than(maxvlue) tablespace orcltbs5
);

范围-散列复合分区
create table student_range_hash(
        sno number(10) primary key,
        sname varchar2(6),
        sage number(4),
        birthday date
)
partition by range(birthday)
subpartition by hash(sno)
(
        partition p1 values less than(to_date('1980-1-1','YYYY-MM-DD'))
        (
                subpartition p1_sub1 tablespace orcltbs1,
                subpartition p1_sub2 tablespace orcltbs2
        ),
        partition p2 values less than(to_date('1990-1-1','YYYY-MM-DD'))
        (
                subpartition p2_sub1 tablespace orcltbs3,
                subpartition p2_sub2 tablespace orcltbs4
        ),
        partition p3 values less than(maxvalue) tablespace orcltbs5
);

维护分区表
创建分区索引
查询分区表和分区索引信息

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值