最近新的项目需要销售数据,我将近3年的销售数据全部倒入  800w条,突然发现有2116条重复数据,Oracle 10G的数据库。一下是我的解决方案,不知道各位有没有更好的方案,要效率的
delete from table1  tt1 where tt1.column1 in(select max(t.rowid )from table1 t group by t.column1,t.column2,t.column3,t.column4having count(t.column1)>1 order by t.sys_storeno)还没有执行  但是我感觉这种方法肯定执行起来很慢。我有想用procedure去做。各位还有别的什么好的方法吗?
ps:最好不要使用临时表去做  800万 oracle 重复数据

解决方案 »

  1.   

    select columns(重复列标识),count(*) from tables
    group by columns(重复列标识)
    having count(*)>1;
      

  2.   

    with t1 as(select columns(重复列标识),count(*) from tables
    group by columns(重复列标识)
    having count(*)>1);
    delete from  tables t where t.columns(重复列标识) in(select t.columns(重复列标识) from t1);
      

  3.   

    就是你的表中字段:t.column1,t.column2,t.column3,t.column4
      

  4.   

    别忘了哈,你的要求是不用临时表,这里的with as 内部实现就是用临时表的
      

  5.   

    "我有想用procedure去做"
    PL/SQL在效率上肯定比SQL稍微低了点
    在数据没有被你取出前,distinct剔重不行吗?基于你的3年销售数据的品质,1楼的方法其实可以考虑
      

  6.   

    谢谢斑竹大人给的建议  已经做好了  还是用最初的办法做的   。
    在数据没有被你取出前,distinct剔重不行吗?
    一言难尽。