資源回收筒(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打開,當我們有誤操作删除表時,還可以到資源回收筒找回(以上隻是我本人的測試,不建議在生産線操作)。
轉載于:https://my.oschina.net/u/3635497/blog/3064389