Heim  >  Artikel  >  Datenbank  >  根据ora_rowscn删除重复插入的数据

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

WBOY
WBOYOriginal
2016-06-07 17:34:19963Durchsuche

今天下班前,突然接到局方电话,要求提供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.starttime>=to_date('2013-10-05 00:00:00','yyyy-mm-dd hh24:mi:ss')
and dt.starttimeand 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.starttimeand 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)

linux

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn