求删除重复记录的SQL语句(不使用临时表方法)ORACLE环境

解决方案 »

  1.   

    delete from tab a
    where exists(select 1 from tab b where a.id=b.id and a.rowid>b.rowid)
      

  2.   

    delete from table_name a where a.rowid!=(select max(rowid) from table_name b where a.id=b.id and a.name=b.name); 
    delete from table_name where rowid not in(select max(rowid) from table_name group by id,name);
      

  3.   


    DELETE FROM table_name t
     WHERE EXISTS (SELECT 1
           FROM table_name h
            WHERE t.ROWID <> h.ROWID
            AND t.column_name = h.column_name)
     AND ROWID <> (SELECT MAX(ROWID)
     FROM table_name d
    WHERE d.column_name = t.column_name);
      

  4.   

    delete from tablename a where a.rowid>(select min(b.rowid) from tablename b where a.id=b.id);
      

  5.   

    rowid + max()delete from stu a where rowid not in (select max(b.rowid) from stu b where a.no=b.no and a.name = b.name and a.sex = b.sex);连接:http://xueruijane.blog.163.com/blog/static/11222525120107211220306//blog/static/11222525120107211220306/
      

  6.   

    http://xueruijane.blog.163.com/blog/static/11222525120107211220306/