ORACLE 回收站当前状态查询整理

回收站(Recycle Bin)从原理上来讲就是一个数据字典表,放置用户删除(drop)掉的数据库对象信息。用户进行删除操做的对象并无被数据库删除,仍然会占用空间。除非是因为用户手工进行Purge或者由于存储空间不够而被数据库清掉。
若是一个表被drop删除,那么与表关联的对象、约束条件、索引都会一并删除。

2种查看回收站的当前状态:(默认是打开的)
SQL> show parameter bin
NAME TYPE VALUE

cursor_bind_capture_destination string memory+disk
recyclebin string on

SQL> SELECT Value FROM V$parameter WHERE Name = 'recyclebin';
VALUE

ON

启动或者关闭回收站里的每一个会话(session)和系统(system),代码以下:

ALTER SYSTEM SET recyclebin = ON;
ALTER SESSION SET recyclebin = ON;
ALTER SYSTEM SET recyclebin = OFF;
ALTER SESSION SET recyclebin = OFF;

注:执行ALTER SESSION SET recyclebin = OFF只适用于当前会话窗口,从新复制新窗口默认回收站依旧是打开的,测试以下:
SQL> ALTER SESSION SET recyclebin = OFF;
Session altered.
新开窗口:
[oracle@strong ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Thu Jan 28 18:03:00 2018
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> show parameter bin
NAME TYPE VALUE

cursor_bind_capture_destination string memory+disk
recyclebin string on

修改system系统级别的测试以下:
SQL> ALTER SYSTEM SET recyclebin = OFF;
ALTER SYSTEM SET recyclebin = OFF
*
ERROR at line 1:
ORA-02096: specified initialization parameter is not modifiable with this
option
报错:不容许这样操做
缘由:回收站是数据文件里面的动态参数,须要添加spoce=spfile,重启数据库才能修改为功


测试以下:
SQL> alter system set recyclebin=off scope=spfile;
System altered.

[root@strong ~]# reboot
Broadcast message from root@strong
(/dev/pts/5) at 18:05 ...
The system is going down for reboot NOW!


[root@strong ~]# su - oracle
[oracle@strong ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Thu Jan 18 18:10:29 2018
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options


SQL> show parameter bin

NAME TYPE VALUE

cursor_bind_capture_destination string memory+disk

recyclebin string OFF


注:生产线上建议把回收站设置为on打开,当咱们有误操做删除表时,还能够到回收站找回(以上只是我本人的测试,不建议在生产线操做)。sql

 

 

 

相关文章
相关标签/搜索