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

 

 

 

相關文章
相關標籤/搜索