10g可以用:alter system set recyclebin=off; 和alter system set recyclebin=on;
11g可以用:alter system set recyclebin=off deferred; 和alter system set recyclebin=on deferred;
2、查看回收站內容
select * from user_recyclebin;
或
select * from recyclebin;--查看當前用戶所drop的對象
select * from dba_recyclebin;--查看所有用戶drop掉的對象
其實當一個對象drop後,並且開啓了回收站功能.它並沒有真正被刪除,實際上只是修改了一下名字,
我們用select * from user_objects where type= 'TABLE'還能查到.只是它的名字有點怪,
例如BIN$qAUuckGyd3TgQKjAFAFTAg==$0,它的命名規範是BIN$unique_id$version,
其中BIN代表RecycleBin, unique_id是數據庫中該對象的唯一標誌,26個字符長度 ,version表示該對象的版本號.
3、還原回收站內容
假如有表test被drop,drop後的object_name是BIN$qAUuckGyd3TgQKjAFAFTAg==$0
可以用flashback table "BIN$qAUuckGyd3TgQKjAFAFTAg==$0" to before drop ;(記得名字加雙引號)
或者flashback table test to before drop ;來還原.不過假如drop掉一個表test,
再新建一個表test,然後再drop.那麼flashback table test to before drop只能還原最後被drop掉的表test.
最先drop掉的表還原時會出錯,因爲表名不能重名.所以必須改名flashback table test to before drop rename to test2
4、清空回收站
如果一次只清空一個表,可以用PURGE table test 或PURGE table "BIN$qAUuckGyd3TgQKjAFAFTAg==$0";
如果一次清空所有的可以用PURGE recyclebin 或者PURGE dba_recyclebin
還原時是隻能一次還原一個表,不能像清空一樣一次還原所有表