闪回delete 恢复

柔情只为你懂 2022-08-09 09:26 243阅读 0赞

误操作语句:

DELETE FROM dbwlhr.t_hrcustom_salarycheck WHERE fid in(
SELECT tt.fid FROM(
SELECT
t.fid,
t.psncode,
t.f_item,
t.f_itemdate,
t.content,
RANK() OVER(PARTITION BY t.psncode ORDER BY t.fid ) r
FROM dbwlhr.t_hrcustom_salarycheck t WHERE t.cyear=’2015’ AND t.cperiod=’09’
AND t.verifyopinion IS NULL
)tt
WHERE tt.r>1);
DELETE FROM dbwlhr.t_hrcustom_salarycheck WHERE fid IN
(SELECT tt1.fid FROM (
SELECT
t.fid,
t.psncode,
t.f_item,
t.f_itemdate,
t.content,
RANK() OVER(PARTITION BY t.psncode ORDER BY t.fid ) r
FROM dbwlhr.t_hrcustom_salarycheck t WHERE t.cyear=’2015’ AND t.cperiod=’09’)tt1
WHERE tt1.r>1)
AND verifyopinion IS NULL;

commit

8079row,39row

恢复方法:

insert into dbwlhr.t_hrcustom_salarycheck

select * FROM dbwlhr.t_hrcustom_salarycheck as of timestamp to_timestamp(‘2015-10-17 11:21:25’, ‘YYYY-MM-DD HH24:MI:SS’)
WHERE fid in (

SELECT tt.fid FROM(
SELECT
fid,
psncode,
f_item,
f_itemdate,
content,
RANK() OVER(PARTITION BY psncode ORDER BY fid ) r
FROM dbwlhr.t_hrcustom_salarycheck as of timestamp to_timestamp(‘2015-10-17 11:21:25’, ‘YYYY-MM-DD HH24:MI:SS’)
WHERE cyear=’2015’ AND cperiod=’09’
AND verifyopinion IS NULL
)tt
WHERE tt.r>1);

cimmit

8079row

insert into dbwlhr.t_hrcustom_salarycheck
select *
FROM dbwlhr.t_hrcustom_salarycheck as of timestamp to_timestamp(‘2015-10-17 11:21:31’, ‘YYYY-MM-DD HH24:MI:SS’)
WHERE fid in (SELECT t.fid
FROM (SELECT fid,
psncode,
f_item,
f_itemdate,
content,
RANK() OVER(PARTITION BY psncode ORDER BY fid) r
FROM dbwlhr.t_hrcustom_salarycheck as of timestamp to_timestamp(‘2015-10-17 11:21:31’, ‘YYYY-MM-DD HH24:MI:SS’)
WHERE cyear = ‘2015’
AND cperiod = ‘09’) t
where t.r > 1)
and verifyopinion IS NULL

and fid not in

(SELECT tt.fid FROM(
SELECT
fid,
psncode,
f_item,
f_itemdate,
content,
RANK() OVER(PARTITION BY psncode ORDER BY fid ) r
FROM dbwlhr.t_hrcustom_salarycheck as of timestamp to_timestamp(‘2015-10-17 11:21:25’, ‘YYYY-MM-DD HH24:MI:SS’)
WHERE cyear=’2015’ AND cperiod=’09’
AND verifyopinion IS NULL
)tt
WHERE tt.r>1);

commit

39 row

原理:闪回查询数据重新插入

其它方法:dbms_flashback.transaction_backout参考临危不惧11g恢复 260页

发表评论

表情:
评论列表 (有 0 条评论,243人围观)

还没有评论,来说两句吧...

相关阅读

    相关 【Oracle】表 drop 后恢复

    今天因为要做一个数据清理的工作,要将仿真环境的数据导入到临时环境里面去进行测试,但是同时间有另一个同事在临时环境做数据整理的工作。 可能是他太过忙了都没有看我发出的通知,到点

    相关 Oracle flashback

    闪回:修复逻辑错误,从当前的点往回退 1.闪回有专门的闪回日志,存放在FIA中,但是只有闪回数据库会用到 2.如果做全数据库的闪回,相当于一次不完全恢复