重庆思庄Oracle、Redhat认证学习论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 3650|回复: 0
打印 上一主题 下一主题

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

[复制链接]
跳转到指定楼层
楼主
发表于 2018-1-29 11:24:39 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 jiawang 于 2018-1-29 11:33 编辑

回收站(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打开,当我们有误操作删除表时,还可以到回收站找回(以上只是我本人的测试,不建议在生产线操作)。

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 支持支持 反对反对
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|手机版|小黑屋|重庆思庄Oracle、Redhat认证学习论坛 ( 渝ICP备12004239号-4 )

GMT+8, 2024-5-19 17:21 , Processed in 0.083734 second(s), 20 queries .

重庆思庄学习中心论坛-重庆思庄科技有限公司论坛

© 2001-2020

快速回复 返回顶部 返回列表