且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

甲骨文|删除重复记录

更新时间:2023-02-02 20:26:56

即使您没有主键,每个记录也会有一个唯一的关联的rowid.

Even if you don't have the primary key, each record has a unique rowid associated.

通过使用下面的查询,您可以通过将表与导致重复的列进行自我连接来仅删除没有最大行ID的记录.这样可以确保您删除所有重复项.

By using the query below you delete only the records that don't have the maximum row id by self joining a table with the columns that cause duplication. This will make sure that you delete any duplicates.

DELETE FROM PPLP_LOAD_GENSTAT plg_outer
WHERE ROWID NOT IN(
  select   MAX(ROWID)
  from     PPLP_LOAD_GENSTAT plg_inner
  WHERE    plg_outer.pplp_name = plg_inner.pplg_name
  AND      plg_outer.start_time= plg_inner.start_time
  AND      plg_outer.end_time  = plg_inner.end_time
);