oracle恢复被覆盖(删除)的视图、表、存储过程、触发器

本文提供了一套完整的Oracle闪回恢复指南,包括视图、表、触发器等不同数据库对象的恢复步骤。从授权到具体命令,详尽地介绍了如何恢复误删或误更新的数据。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一.恢复被覆盖(删除)的视图:

  1. 授权:使用sys用户登陆,执行命令 grant flashback on sys.dba_views to cmms3;
  2. 执行以下语句查询某个时间点的视图
select * from SYS.DBA_views
as of timestamp to_date('20170306105700','yyyymmddhh24miss')
where view_name='V_HX_DUTY_AIM';

二.恢复被 delete 的表:
1.查看操作时间:

 SELECT c.username,
         a.program,
         b.sql_text,
         b.command_type,
         a.sample_time
    FROM dba_hist_active_sess_history a
         JOIN dba_hist_sqltext b
            ON a.sql_id = b.sql_id
         JOIN dba_users c
            ON a.user_id = c.user_id
   WHERE     a.sample_time BETWEEN SYSDATE - 1/3 AND SYSDATE
         AND b.command_type IN (7, 85)
ORDER BY a.sample_time DESC;

或者
select * from tableName as of timestamp to_timestamp(‘2018-03-16 11:40:00’,‘YYYY-MM-DD HH24:MI:SS’);

2、查询删除数据的时间点的数据

    select * from ALLVIEW.WP_OBJECT as of timestamp to_timestamp('2017-11-20 11:30:31','yyyy-mm-dd hh24:mi:ss');            

3、恢复删除且已提交的数据

 flashback table ALLVIEW.WP_OBJECT to timestamp to_timestamp('2017-11-20 11:30:00','yyyy-mm-dd hh24:mi:ss');

–注意:如果在执行上面的语句,出现错误。可以尝试执行 alter table 表名 enable row movement; //允许更改时间戳

三.恢复被 upate的表:
1.查看操作时间:

 select r.FIRST_LOAD_TIME,r.* from v$sqlarea r where SQL_TEXT like '%update mc_gd_cust_other_info%' order by r.FIRST_LOAD_TIME desc ;

其中’%update mc_gd_cust_other_info%’ 为模糊查找update的语句

2、创建临时表保存该时间点数据:


create table mc_gd_cust_other_info_recove --新表
as
select * from mc_gd_cust_other_info--你操作的那张表  
as of timestamp to_timestamp('2018-01-10 16:28:18','yyyy-mm-dd hh24:mi:ss');

3.确认数据正确,清空数据表,插入恢复的表数据到正式表

delete from mc_gd_cust_other_info;
insert into mc_gd_cust_other_info
  select * from mc_gd_cust_other_info_recove

四.恢复被覆盖(删除)的触发器:

  1. 授权:使用sys用户登陆,执行命令 grant flashback on sys.dba_triggers to cmms3;
  2. 执行以下语句查询某个时间点的触发器
    注意:删除表会自动删除关联的触发器
select * from SYS.dba_triggers
as of timestamp to_date('20200407153000','yyyymmddhh24miss')
where trigger_name='TRIGGER_UNIFIED_ACCOUNT_COMMON';
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值