---
title: "oracle删除重复数据"
author: "roc08"
date: "2015-01-15T11:16:47Z"
tags: []
categories: ["数据库"]
slug: "oracle"
draft: false
lastmod: "2015-01-15T11:16:47Z"
id: 2176115
url: "https://roc08.iteye.com/blog/2176115"
---

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