语法
删除分区表的分区:
alter table Partition_Table drop partition Partition_Name update indexes;
删除子分区表的分区:
alter table Partition_Table drop subpartition Partition_Name update indexes;
1.创建样例分区表
sec@ora10g> create table t_partition_range (id number,name varchar2(50))
2 partition by range(id)(
3 partition t_range_p1 values less than (10) tablespace tbs_part01,
4 partition t_range_p2 values less than (20) tablespace tbs_part02,
5 partition t_range_p3 values less than (30) tablespace tbs_part03,
6 partition t_range_pmax values less than (maxvalue) tablespace tbs_part04);
Table created.
sec@ora10g> select table_name,partition_name,high_value,tablespace_name from user_tab_partitions where table_name='T_PARTITION_RANGE' order by partition_position;
TABLE_NAME PARTITION_NAME HIGH_VALUE TABLESPACE_NAME
-------------------- -------------------- ---------- ---------------
T_PARTITION_RANGE T_RANGE_P1 10 TBS_PART01
T_PARTITION_RANGE T_RANGE_P2 20 TBS_PART02
T_PARTITION_RANGE T_RANGE_P3 30 TBS_PART03
T_PARTITION_RANGE T_RANGE_PMAX MAXVALUE TBS_PART04
2.删除T_RANGE_P3分区
sec@ora10g> alter table t_partition_range drop partition T_RANGE_P3 update indexes;
Table altered.
sec@ora10g> select table_name,partition_name,high_value,tablespace_name from user_tab_partitions where table_name='T_PARTITION_RANGE' order by partition_position;
TABLE_NAME PARTITION_NAME HIGH_VALUE TABLESPACE_NAME
-------------------- -------------------- ---------- ---------------
T_PARTITION_RANGE T_RANGE_P1 10 TBS_PART01
T_PARTITION_RANGE T_RANGE_P2 20 TBS_PART02
T_PARTITION_RANGE T_RANGE_PMAX MAXVALUE TBS_PART04
3.删除分区是较迅速的清理数据的手段(因为是DDL语句)
sec@ora10g> select * from t_partition_range partition(t_range_p1);
ID NAME
---------- --------------------------------------------------
5 Andy1
5 Andy1
5 Andy1
5 Andy1
5 Andy1
5 Andy1
6 rows selected.
sec@ora10g> select * from t_partition_range;
ID NAME
---------- --------------------------------------------------
5 Andy1
5 Andy1
5 Andy1
5 Andy1
5 Andy1
5 Andy1
6 rows selected.
sec@ora10g> alter table t_partition_range drop partition t_range_p1 update indexes;
Table altered.
sec@ora10g> select * from t_partition_range partition(t_range_p1);
select * from t_partition_range partition(t_range_p1)
*
ERROR at line 1:
ORA-02149: Specified partition does not exist
sec@ora10g> select * from t_partition_range;
no rows selected
这也体现了分区技术在海量数据库的维护上的灵活性。
-- The End --
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/70034820/viewspace-2993961/
,如需转载,请注明出处,否则将追究法律责任。