数据库查重复值

以前处理故障时候,遇到特殊情况下,表中的数据出现重复,可以巧用rowid 处理重复数据
create table test1(id integer,city varchar2(100),levle varchar2(4));
select * from test1;
insert into test1 values(1,'hangzhou','1');
insert into test1 values(2,'binjiang','2');
insert into test1 values(3,'chengxi','2');
insert into test1 values(4,'yuhang','3');
insert into test1 values(1,'hangzhou','1');
insert into test1 values(2,'binjiang','2');
insert into test1 values(3,'chengxi','2');
insert into test1 values(4,'yuhang','2');

select * from test1 where rowid in(
         select min(rowid) from test1 group by id having count(1)>1)

就找出了重复的数据,可以做删除 修改处理
 

你可能感兴趣的:(代码示例,数据库)