[原创] 当表空间不足时,Oracle是这样管理Recyclebin

我们知道,在Oracle 10g中,drop table如果没有加 purge选项.实际数据并没有删除,因而没有释放表空间.
那么当被删除的对象占用了所有空间时,会发生什么? 相信看完以下测试,一切皆会明白

YXYUP@dbatest>select tablespace_name,sum(bytes)/1024/1024 from dba_data_files where tablespace_name='TBS' group by tablespace_name;

TABLESPACE_NAME      SUM(BYTES)/1024/1024
-------------------- --------------------
TBS                                    17

Elapsed: 00:00:00.02

YXYUP@dbatest>select segment_name,bytes/1024/1024,tablespace_name from user_segments;

SEGMENT_NAME                   BYTES/1024/1024 TABLESPACE_NAME
------------------------------ --------------- --------------------
TEST_BAK                                     6 TBS
TEST01                                       6 TBS

Elapsed: 00:00:00.07

YXYUP@dbatest>create table test02 tablespace tbs as select * from dba_objects;
create table test02 tablespace tbs as select * from dba_objects
                                                    *
ERROR at line 1:
ORA-01652: unable to extend temp segment by 128 in tablespace TBS


Elapsed: 00:00:00.73

YXYUP@dbatest>drop table test01;

Table dropped.

Elapsed: 00:00:00.04

YXYUP@dbatest>show recyclebin;
ORIGINAL NAME    RECYCLEBIN NAME                OBJECT TYPE  DROP TIME
---------------- ------------------------------ ------------ -------------------
TEST01           BIN$VPH4ibnKVd/gQAB/AQA0Nw==$0 TABLE        2008-08-21:14:56:55
YXYUP@dbatest>
YXYUP@dbatest>select * from tab;

TNAME                          TABTYPE  CLUSTERID
------------------------------ ------- ----------
BIN$VPH4ibnKVd/gQAB/AQA0Nw==$0 TABLE
TEST_BAK                       TABLE

Elapsed: 00:00:00.01

YXYUP@dbatest>create table test02 tablespace tbs as select * from dba_objects;

Table created.

Elapsed: 00:00:00.84

YXYUP@dbatest>show recyclebin;
YXYUP@dbatest>select * from tab;

TNAME                          TABTYPE  CLUSTERID
------------------------------ ------- ----------
TEST_BAK                       TABLE
TEST02                         TABLE

Elapsed: 00:00:00.01

上面测试可以看出,当表空间空闲空间不足时,Oracle就会将recyclebin中的表给彻底删除,然后腾出空间来放要创建的新对象.
那么,如果recyclebin中有多个被drop的对象时,Oracle会怎么清理呢,是全部清除,还是怎样? 通过下面的测试我们行到答案.


YXYUP@dbatest>show recyclebin;
YXYUP@dbatest>select * from tab;

TNAME                          TABTYPE  CLUSTERID
------------------------------ ------- ----------
TEST_BAK                       TABLE
TEST02                         TABLE

Elapsed: 00:00:00.01
YXYUP@dbatest>drop table test02;

Table dropped.

Elapsed: 00:00:00.04
YXYUP@dbatest>drop table test_bak;

Table dropped.

Elapsed: 00:00:00.02
YXYUP@dbatest>select * from tab;                                              

TNAME                          TABTYPE  CLUSTERID
------------------------------ ------- ----------
BIN$VPH4ibnLVd/gQAB/AQA0Nw==$0 TABLE
BIN$VPH4ibnMVd/gQAB/AQA0Nw==$0 TABLE

Elapsed: 00:00:00.01

YXYUP@dbatest>show recyclebin;
ORIGINAL NAME    RECYCLEBIN NAME                OBJECT TYPE  DROP TIME
---------------- ------------------------------ ------------ -------------------
TEST02           BIN$VPH4ibnLVd/gQAB/AQA0Nw==$0 TABLE        2008-08-21:15:14:43
TEST_BAK         BIN$VPH4ibnMVd/gQAB/AQA0Nw==$0 TABLE        2008-08-21:15:14:51

YXYUP@dbatest>create table test01 tablespace tbs as select * from dba_objects;

Table created.

Elapsed: 00:00:00.79
YXYUP@dbatest>select * from tab;      

TNAME                          TABTYPE  CLUSTERID
------------------------------ ------- ----------
BIN$VPH4ibnMVd/gQAB/AQA0Nw==$0 TABLE
TEST01                         TABLE

Elapsed: 00:00:00.01

YXYUP@dbatest>flashback table TEST02 to before drop ;
flashback table TEST02 to before drop
*
ERROR at line 1:
ORA-38305: object not in RECYCLE BIN


Elapsed: 00:00:00.00

YXYUP@dbatest>flashback table TEST_BAK to before drop ;

Flashback complete.

Elapsed: 00:00:00.02

YXYUP@dbatest>select * from tab;      

TNAME                          TABTYPE  CLUSTERID
------------------------------ ------- ----------
TEST_BAK                       TABLE
TEST01                         TABLE

Elapsed: 00:00:00.01

通过上面测试可以看出.
当recyclebin中有多个被删除的同时,并在表空间不足以放下要创建的新对象时,Oracle会FIFO的方式从回收站中自动彻底删除.

 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/7364032/viewspace-432974/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/7364032/viewspace-432974/

你可能感兴趣的:([原创] 当表空间不足时,Oracle是这样管理Recyclebin)