Home > Database > Mysql Tutorial > body text

关于如何删除Oracle数据库中重复记录

WBOY
Release: 2016-06-07 17:00:47
Original
959 people have browsed it

看了点Oracle数据库的东西,因为遇到了一些数据库的问题。对于Oracle数据库一个表中的记录,如果有重复值如何进行删除。我现在将

看了点Oracle数据库的东西,因为遇到了一些数据库的问题。

对于Oracle数据库一个表中的记录,如果有重复值如何进行删除。我现在将的作法记录下来以备忘。我所用的数据为oracle.

假设有下一个表

create table test (name varchar2(255),pass varchar2(255));

如果数据库有多行重复的记录,该如何处理。查了资料,,有人说用临时表..反正方法很多。对于oracle数据库,它有一个rowid,它是永远也不会重复的。我们可以利用这个来处理重复记录。

delete from test t where t.rowid not in(
select c.r from (
   select distinct z.name,min(z.rowid) r from test z group by z.name
)c
)

这样可以将rowid较大,而记录重复的值删掉。当然这个也可以用来删除数据库表中单列重复的记录。

linux

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!