标签:语句 rowid delete har min values src sele com
预先准备
create table p( name varchar2(10) ); insert into p values(‘黄伟福‘); insert into p values(‘赵洪‘); insert into p values(‘杨华‘);
每条语句执行三次插入
select rowid,p.* from p;
select distinct * from p;
查询最小rowID,只返回了一条数据
select min(rowid) from p p1 where p1.name = p1.name
查询每个重复名字的最小rowID,注意子查询返回的是3条数据,并不是一条,思考一下具体执行顺序
select rowid,p1.* from p p1 where rowid = (select min(rowid) from p p2 where p1.name = p2.name);
删除重复数据,只保存数据中的最小rowID ,然后查询
delete from p p1 where rowid > (select min(rowid) from p p2 where p1.name = p2.name); select rowid,p.* from p;
标签:语句 rowid delete har min values src sele com
原文地址:https://www.cnblogs.com/duanwandao/p/9879714.html