警惕:Oracle中删除的分区不会进入回收站(Recyclebin)

时间:2022-05-03
本文章向大家介绍警惕:Oracle中删除的分区不会进入回收站(Recyclebin),主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

在Oracle数据库中,单个删除的分区并不会进入回收站,全表删除的分区才可能和全表一起放入回收站。这是因为单个分区删除之后,是无法通过简单的闪回加入原分区表中,既然无法保证一致性,这个分区就不会进入回收站中。

以下这个测试展示了这个过程:

SQL> select * from v$version;
BANNER 
-------------------------------------------------------------------
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production  
PL/SQL Release 12.2.0.1.0 - Production  
CORE 12.2.0.1.0 Production  
TNS for Linux: Version 12.2.0.1.0 - Production  
NLSRTL Version 12.2.0.1.0 - Production  
SQL> CREATE TABLE enmotech (
2 PartID  integer  not null,
3 CretTm  date  not null,
4 PartCD  varchar2(2) not null
5 ) partition by list (partcd) automatic (
6 partition pBJ values ('BJ'),
7 partition pCD values ('CD'),
8 partition pGZ values ('GZ'),
9 partition pSH values ('SH')
10 );
Table created.
SQL> insert into enmotech values (1, sysdate, 'KM');
1 row created.
SQL> select partition_name from user_tab_partitions
2 where table_name = 'ENMOTECH';
PARTITION_NAME
--------------------------------------------------------------------
PBJ
PCD
PGZ
PSH
SYS_P281
SQL> alter table enmotech drop partition SYS_P281 purge;
alter table enmotech drop partition SYS_P281 purge
*
ERROR at line 1:
ORA-14048: a partition maintenance operation may not be combined with other operations
SQL> alter table enmotech drop partition PSH;
Table altered.
SQL> select * from user_recyclebin;
no rows selected

当我们DROP 整个分区表时,分区表连带所有的分区,会进入到回收站。

很多时候,想当然的结果可能并不可信,实践操作方能出真知,多动手,是技术人的王道。