ORACLE 回收站当前状态查询整理
时间: 2019-06-20来源:OSCHINA
前景提要
「深度学习福利」大神带你进阶工程师,立即查看>>>
回收站(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打开,当我们有误操作删除表时,还可以到回收站找回(以上只是我本人的测试,不建议在生产线操作)。



科技资讯:

科技学院:

科技百科:

科技书籍:

网站大全:

软件大全:

热门排行