警惕:Oracle中删除的分區不會進入資源回收筒(Recyclebin)

最近在『雲和恩墨大講堂』的微信群讨論中,有朋友提到分區的删除和閃回問題,我注意到很多人可能忽略了這個問題。
在Oracle資料庫中,單個删除的分區并不會進入資源回收筒,全表删除的分區才可能和全表一起放入資源回收筒。這是因為單個分區删除之後,是無法通過簡單的閃回加入原分區表中,既然無法保證一緻性,這個分區就不會進入資源回收筒中。
以下這個測試展示了這個過程:
SQL> select * from v$version;
BANNER CON_ID
-------------------------------------------------------------------------------- ----------
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production 0
PL/SQL Release 12.2.0.1.0 - Production 0
CORE12.2.0.1.0Production 0
TNS for Linux: Version 12.2.0.1.0 - Production 0
NLSRTL Version 12.2.0.1.0 - Production 0
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
SQL> drop table enmotech;
Table dropped.
SQL> select object_name,original_name,type from user_recyclebin;
OBJECT_NAME ORIGINAL_NAME TYPE
---------------------------------------- -------------------- -------------------------
BIN$TflQLiTmWX7gUwo4qMBX+A==$0 ENMOTECH TABLE
BIN$TflQLiTmWX7gUwo4qMBX+A==$0 ENMOTECH Table Partition
BIN$TflQLiTmWX7gUwo4qMBX+A==$0 ENMOTECH Table Partition
BIN$TflQLiTmWX7gUwo4qMBX+A==$0 ENMOTECH Table Partition
BIN$TflQLiTmWX7gUwo4qMBX+A==$0 ENMOTECH Table Partition
很多時候,想當然的結果可能并不可信,實踐操作方能出真知,多動手,是技術人的王道。
By eygle on 2017-04-25 16:07 |
Comments (0) |
FAQ | 3249 |