警惕: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 整個分區表時,分區表連帶所有的分區,會進入到回收站。
很多時候,想當然的結果可能並不可信,實踐操作方能出真知,多動手,是技術人的王道。
文章轉自數據和雲公眾號,原文鏈接
最後更新:2017-07-17 17:03:07