一.恢复被覆盖(删除)的视图:
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
四.恢复被覆盖(删除)的触发器:
select * from SYS.dba_triggers
as of timestamp to_date('20200407153000','yyyymmddhh24miss')
where trigger_name='TRIGGER_UNIFIED_ACCOUNT_COMMON';