ITPub博客

首页 > 数据库 > Oracle > oracle recyclebin和flashback

oracle recyclebin和flashback

原创 Oracle 作者:chenfengwww 时间:2012-07-17 00:14:06 0 删除 编辑
select * from dba_recyclebin where owner = 'GAPS1' and type = 'TABLE'
flashback table YW_CUPSATM_HXDZMX to before drop
select * from dba_audit_trail
查看所有用户权限
select * from dba_role_privs t where t.granted_role='DBA'[@more@]

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
还可以指定某个表空间和某个用户下表。

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

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


删除索引: purge index origenal_indexname

如果清空回收站:

purge recyclebin;


FLASHBACK闪回表

今天误删除表里面的数据,通过FLASHBACK闪回,

flashback table mmdb.column_class_def_t to timestamp to_timestamp('2009-03-24 14:40:00','yyyy-mm-dd hh24:mi:ss');

出现因为未启用行移动功能,不能闪回表。

运行alter table mmdb.column_class_def_t enable row movement;然后再运行FLASHBACK,OK

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/22036495/viewspace-1058825/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2009-07-04

  • 博文量
    118
  • 访问量
    460775