2010年01月03日 flashback query@20091208

抓取库丢失了一批项目数据,考虑到闪回表的执行效率过低,同时为了查明丢失原因,于是采用闪回查询的方法进行查找。

首先将时间转换成SCN:

select timestamp_to_scn(to_timestamp('2009-12-08 09:00:00', 'yyyy-mm-dd hh24:mi:ss')) from dual;

然后以SCN进行闪回查询:

select count(*) from auto_web_basic_biz_info as of scn 35342231633 where web_id=21663;

为了加快速度,考虑以两小时为间隔点,以发现数据丢失的时间为起点逆推,观察数据量变化(可采用文本编辑器或SQL批量生成闪回语句);最后发现此批数据每到凌晨1点15分左右便会自动清空归零,怀疑是某个JOB所致,结果发现数据库在01:00am挂了一个清理无效数据的prc_webdata_clean,内容如下:

create or replace procedure prc_webdata_clean
is
begin
delete from auto_web_basic_biz_info t
where t.bizname is null and t.phone is null
and t.fax is null and t.contact is null
and t.email is null and t.homepage is null;

commit;
end;

由于此批数据属于特殊抓取,where条件里的字段基本都为null,因此。。。

之后通过CTAS+FLASHBACK将每天凌晨1点之前的数据取回、去重及合并,修改prc_webdata_clean将21663批次排除,收工。

Rand Posts:



我们在天上的父
愿人都尊你的名为圣
愿你的国降临
愿你的旨意行在地上如同行在天上
我们将顺着你的指引前行
直至重归你的梯下


评论

0条评论

发表评论

文明上网,共建和谐社会。