闪回delete 恢复

误操作语句:

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页


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值