SQL> select * from testrp;
A B
---------- ----------
1 1
50 50
51 51
80 80
81 81_new
已选择6行。
SQL> select * from testrp partition(testrp1);
A B
---------- ----------
1 1
50 50
SQL> select * from testrp partition(testrp2);
A B
---------- ----------
51 51
80 80
SQL> select * from testrp partition(testrp3);
A B
---------- ----------
81 81_new
SQL> alter table testrp merge partitions testrp2, testrp3 into partition testrp2;
alter table testrp merge partitions testrp2, testrp3 into partition testrp2
*
ERROR 位于第 1 行:
ORA-14275: 不能将下界分区作为结果分区重用
SQL> alter table testrp merge partitions testrp2, testrp3 into partition testrp3;
表已更改。
SQL> select * from testrp;
A B
---------- ----------
1 1
50 50
51 51
80 80
81 81_new
已选择6行。
SQL> select * from testrp partition(testrp1);
A B
---------- ----------
1 1
50 50
SQL> select * from testrp partition(testrp2);
select * from testrp partition(testrp2)
*
ERROR 位于第 1 行:
ORA-02149: 指定的分区不存在
SQL> select * from testrp partition(testrp3);
A B
---------- ----------
51 51
80 80
81 81_new
--7.2分裂:分裂后,该分区中的数据按照分区键值分配到新分区中。
SQL> alter table testrp split partition testrp3 at(81) into (
2 partition testrp2 tablespace tp_p2,
3 partition testrp3 tablespace tp_p3
4 );
表已更改。
SQL> select * from testrp partition(testrp2);
A B
---------- ----------
51 51
80 80
SQL> select * from testrp partition(testrp3);
A B
---------- ----------
81 81_new
--7.3删除:删除分区后,该分区中的数据被一并删除。慎重使用。
SQL> alter table testrp drop partition testrp3;
表已更改。
SQL> select * from testrp;
A B
---------- ----------
1 1
50 50
51 51
80 80
SQL> select * from testrp partition(testrp1);
A B
---------- ----------
1 1
50 50
SQL> select * from testrp partition(testrp2);
A B
---------- ----------
51 51
80 80
SQL> select * from testrp partition(testrp3);
select * from testrp partition(testrp3)
*
ERROR 位于第 1 行:
ORA-02149: 指定的分区不存在
--7.4重命名:对数据没有影响。
SQL> alter table testrp rename partition testrp2 to testrp02
表已更改。
SQL> select * from testrp;
A B
---------- ----------
1 1
50 50
51 51
80 80
SQL> select * from testrp partition(testrp1);
A B
---------- ----------
1 1
50 50
SQL> select * from testrp partition(testrp2);
select * from testrp partition(testrp2)
*
ERROR 位于第 1 行:
ORA-02149: 指定的分区不存在
SQL> select * from testrp partition(testrp02);
A B
---------- ----------
51 51
80 80
--8.可以截短指定分区
SQL> alter table testrp truncate partition testrp02;
表已截掉。
SQL> select * from testrp;
A B
---------- ----------
1 1
50 50
SQL> select * from testrp partition(testrp1);
A B
---------- ----------
1 1
50 50
SQL> select * from testrp partition(testrp02);
未选定行