根據ora_rowscn重複資料刪除插入的資料

來源:互聯網
上載者:User

今天下班前,突然接到局方電話,要求提供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.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)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.