• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

根据ora_rowscn删除重复插入的数据

mysql 搞代码 4年前 (2022-01-09) 17次浏览 已收录 0个评论

今天下班前,突然接到局方电话,要求提供10月详单通话记录。 这下就开始整,结果不小心,把提取的记录全部插入到了详单表。这下好

今天下班前,突然接到局方电话,要求提供10月详单通话记录。

这下就开始整,结果不小心,把提取的记录全部插入到了详单表。这下好了,几十w条重复记录,,在1000亿大表中,删除嘛。

–下面是解决方案:

–1.找出提交值 ora_rowscn

— select scn_to_timestamp(ora_rowscn) from dual 查看提交时间

select /*+ parallel(12) */ dt.ora_rowscn,count(*) from table_name(涉及隐私) dt, table_b(涉及隐私) cp
where dt.st本文来源gaodai$ma#com搞$代*码网2arttime>=to_date(‘2013-10-05 00:00:00′,’yyyy-mm-dd hh24:mi:ss’)
and dt.starttime<to_date('2013-10-06 00:00:00','yyyy-mm-dd hh24:mi:ss')
and dt.called in (‘123456′,’xxxxx’)
and substr(dt.caller,1,3) in (‘..’,’..’,’….’)
and dt.xxx=cp.xx
and cp.ldcflag=1
–and dt.ora_rowscn=31902278734
group by dt.ora_rowscn
order by 2 desc
;


–验证时间
select scn_to_timestamp(31903242189) from dual

–验证条数
–select 10910+1841 from dual

–创建表
create table rowid_4 as
select rowid rowids from table_name (涉及隐私) dt
where dt.starttime>=to_date(‘2013-10-04 00:00:00′,’yyyy-mm-dd hh24:mi:ss’)
and dt.starttime<to_date('2013-10-05 00:00:00','yyyy-mm-dd hh24:mi:ss')
and dt.ora_rowscn in (31901488022,31905491128)

–验证条数
select count(*) from rowid_4;

–根据rowid删除重复数据
delete /*+ parallel(8) nologging use_hash(dt ssd )*/ from table_name (涉及隐私) dt
where dt.rowid in (select rowids from rowid_4 ssd)


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:根据ora_rowscn删除重复插入的数据

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址