欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

oracle 联合主键去重,并删除重复数据

程序员文章站 2022-06-02 13:02:39
...

 

---去重
select XK_XDR_MC, XK_LYDWDM, XK_XKJGDM, XK_WSH, XK_JDRQ, XK_XKBH, count(1)
from T_XZxks
group by XK_XDR_MC, XK_LYDWDM, XK_XKJGDM, XK_WSH, XK_JDRQ, XK_XKBH
having count(1) > 1

--删除重复

delete from  T_XZxks where rowid not in(
 select max(rowid) from T_XZxks group by(XK_XDR_MC, XK_LYDWDM, XK_XKJGDM, XK_WSH, XK_JDRQ, XK_XKBH));

 

相关标签: 数据库