Home  >  Article  >  Database  >  Oracle的recyclebin

Oracle的recyclebin

WBOY
WBOYOriginal
2016-06-07 17:18:16913browse

Oracle10G以前执行drop table后表就即被删除了。10G后引入了垃圾回收站的概念recyclebin。如果仍只是drop table xxx,表不会立即

Oracle10G以前执行drop table后表就即被删除了。10G后引入了垃圾回收站的概念recyclebin。如果仍只是drop table xxx,表不会立即被删除,而是被暂时放入回收站。
可以保障某些误操作后还可以将表还原。

1.查看数据库是否开户recyclebin功能
SQL> show parameter recyclebin;

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
recyclebin                           string      on

或者只将当前会话开启功能
alter session set recyclebin = on;
2.查看当前用户中的垃圾回收站的对象:
select * from recyclebin;

3.drop table xxx时,不希望将表放入垃圾回收站,,而是直接drop
drop table xxx purge;

4.将recyclebin中对象还原或清除
--还原
flashback table "xxxxx" to before drop
"xxxx"乃是recyclebin视图中OBJECT_NAME字段名称
flashback table "xxxxx" to before drop
亦可换成
flashback table "xxxxx" to before drop  rename to xxxx重命名

--清除
purge table xxxx

purge recyclebin
还可以指定某个表空间和某个用户下表。

ps:
recycelbin中还保留了index。
如个表空间不够创建新对象时,oracle将自动请除recyclebin中的对象。
以下几种drop不会将相关对象放进RecycleBin:

    * drop tablespace:会将RecycleBin中所有属于该tablespace的对象清除
    * drop user:会将RecycleBin中所有属于该用户的对象清除
    * drop cluster:会将RecycleBin中所有属于该cluster的成员对象清除
    * drop type:会将RecycleBin中所有依赖该type的对象清除

linux

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn