日期:2014-05-16  浏览次数:20399 次

oracle 删除数据表中的重复
/* 删除重复的反馈表的数据*/
  procedure PRO_CZW_DEL_DOU_FEEBACK as
  begin
    begin
      for rec in (select row_number() over(
           partition by t.ywlsh  /*指定的重复列*/
           order by t.id desc) as lev, /*指定的重复列的排序*/
                         t.*
                    from T_CZW_YW_FEEDBACK t
                   where exists (select 1
                            from T_CZW_YW_FEEDBACK k
                           where k.ywlsh = t.ywlsh
                           group by k.ywlsh
                          having count(*) > 1)) loop
        if rec.lev = 1 then
          null;
        else
          delete T_CZW_YW_FEEDBACK t where t.id = rec.id;
        end if;
      end loop;
    end;
    commit;
  end PRO_CZW_DEL_DOU_FEEBACK;