select rowid ,a.* from cust1 a where a.rowid> (select min(b.rowid) from cust1 b where a.id=b.id )
delete from cust1 a where a.rowid> (select min(b.rowid) from cust1 b where a.id=b.id )
Oracle中删除表中相同记录的分析
分两种情况:
1,删除所有字段均相同的行:
create table tablexxx as (select * from tableyyy group by col1,col2,col3…)
drop table tableyyy
create table tableyyy as (select * from tablexxx)
drop table tablexxx
2,表中有id列,删除另一字段name取值相同的行:
delete b where id not in
(
select min(id) from B
group by name
)
delete from cust1 a where a.rowid> (select min(b.rowid) from cust1 b where a.id=b.id )
Oracle中删除表中相同记录的分析
分两种情况:
1,删除所有字段均相同的行:
create table tablexxx as (select * from tableyyy group by col1,col2,col3…)
drop table tableyyy
create table tableyyy as (select * from tablexxx)
drop table tablexxx
2,表中有id列,删除另一字段name取值相同的行:
delete b where id not in
(
select min(id) from B
group by name
)
本文介绍在Oracle数据库中如何使用SQL语句删除表内重复记录的方法。包括两种常见场景:一是删除所有字段完全相同的记录;二是当表中含有ID列时,如何删除其他字段如name取值相同的行。
1124

被折叠的 条评论
为什么被折叠?



