|
Author: Bo Tang
1. 间隔分区主表:
- create table t0_a (a number,
- b varchar2(20),
- constraint pk_t0_a primary key(b)
- )
- partition by range(a)
- interval (10)
- (partition p1 values less than (10)
- );
复制代码
2. 引用分区子表:
- create table t0_b (aa number,
- bb varchar2(20) not null,
- cc date,
- constraint fk_t0_b foreign key(bb) references t0_a on delete cascade
- )
- partition by reference (fk_t0_b);
复制代码
3. 向扩展分区主表插入数据,向引用分区子表插入数据:
- insert into t0_a values ( 1,'a');
- insert into t0_a values ( 10,'b');
- insert into t0_a values ( 20,'c');
- commit;
- select * from t0_a;
- insert into t0_b values ( 100,'b',sysdate);
- insert into t0_b values ( 200,'c',sysdate);
- commit;
复制代码
4. 查看数据字典:- select * from user_tab_partitions where table_name in ('T0_A','T0_B');
复制代码
5. 进行级联删除测试:
- alter table t0_a truncate partition ( p1) cascade;
- select * from t0_b partition ( p1);
复制代码
|
|