oracle删除重复数据

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

猜你喜欢

转载自roc08.iteye.com/blog/2176115
今日推荐