oracle 刪除資料表中的重複

來源:互聯網
上載者:User

/* 重複資料刪除的反饋表的資料*/  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;

相關文章

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.