recyclebin清理

     今天遇到生产库上某一个段在dba_segments中占看18个G,而且命名规范是BIN$开头的,联想到回收站没有清理导致的(生产库上recyclebin是off状态),随即在测试库中做一把测试:

     

SQL> conn vage/vage
Connected.

创建测试table

SQL> create table test4 tablespace tp02 as select * from dba_objects;

Table created.

查看recyclebin状态:

SQL> show parameter recyclebin

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
recyclebin string ON

删除测试table:test4

SQL> drop table test4;

Table dropped.

查询到回收站中有记录:

SQL> select object_name from recyclebin;

OBJECT_NAME

---------------------------------------------

BIN$Grm0wycYHkDgUwEAAH+t/A==$0

现在不做purge回收站,直接关掉recyclebin=OFF

alter system set recyclebin=off scope=spfile;

SQL> startup
ORACLE instance started.

Total System Global Area 450953216 bytes
Fixed Size 2254144 bytes
Variable Size 364907200 bytes
Database Buffers 79691776 bytes
Redo Buffers 4100096 bytes
Database mounted.
Database opened.
SQL> select segment_name,bytes/1024/1024 bytes from dba_segments where segment_name='BIN$Grm0wycYHkDgUwEAAH+t/A==$0';

SEGMENT_NAME
--------------------------------------------------------------------------------
BYTES
----------
BIN$Grm0wycYHkDgUwEAAH+t/A==$0
20

SQL> select object_name from recyclebin;

no rows selected

数据库起来后发现recyclebin已经没有记录了,但是dba_segments里面还是存在记录

SQL> select object_name from dba_recyclebin;

OBJECT_NAME
------------------------------
BIN$Grm0wycYHkDgUwEAAH+t/A==$0

db_recyclebin 视图中也存在记录,需要purge dba_recyclebin才能彻底清空回收站;

SQL> purge dba_recyclebin;

DBA Recyclebin purged.

SQL> select object_name from dba_recyclebin;

no rows selected

至此回收站清理完毕,回收站机制也关闭了。

生产库关闭recyclebin=OFF的之前最后先清理一下回收站,然后在关闭(前提是确保不会再需要恢复回收站的数据)。

仅做记录,2015-07-13 PM

vage

原文地址:https://www.cnblogs.com/vage/p/4642597.html