ITeye博客

oracle删除重复数据

roc08 · 2015-01-15 11:16 · 数据库 · Markdown

oracle数据库中如果有些记录字段是重复的,需要将这些数据删除掉,如果要删除的两条记录无论删哪个都可以,可采用下面这个方法:

例如学生表student中,学生姓名name和学号stu_no是重复的就删除掉一条。

select * from student a,student b where a.name = b.name and a.stu_no= b.stu_no and a.rowid < b.rowid

delete from student a where a.rowid<( select max(rowid) from student b where a.name = b.name and a.stu_no= b.stu_no)

参考http://blog.csdn.net/onebigday/article/details/5715973

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。