如何用Oracle归档日志恢复到之前的某个时间点

2025-05-20 12:18:56
推荐回答(1个)
回答1:

两种方式

1. 通过scn回复删除并且提交的数据
1.1. 获取当前数据库的scn号
select current_scn from v$database; (切换到sys用户或system用户查询)
查询到的scn号为:1499220
1.2. 查询当前scn之前的scn
select * from 表名 as ofscn 1499220; (确定删除的数据是否存在,如果存在,则恢复数据;如果不是,则继续缩小scn号)
1.3. 恢复数据
flashback table 表名 to scn 1499220;
ORA-08189: cannot flashback the table because rowmovement is not enabled.(ORA-08189: 因为未启用行移动功能, 不能闪回表。)
解决办法:alter tabletable_name enable row movement;
2. 通过时间恢复删除并且提交的数据
2.1. 查询当前系统时间
selectto_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual;
2.2. 查询删除时间点的数据信息
select * from t_b_Student as of timestampto_timestamp('2017-07-10 14:31:46','yyyy-mm-dd hh24:mi:ss');
2.3. 恢复数据
flashback table t_b_Student to timestampto_timestamp('2017-07-10 14:31:46','yyyy-mm-dd hh24:mi:ss');