首页 > 代码库 > Oracle_语句

Oracle_语句

1、删除 数据库中 重复的记录

1)
select * into #temp from (
select KaiGuanDuan,RongLiangPercent,Hz,RongLiangValue,P,Q,row_number() over(partition by KaiGuanDuan,RongLiangPercent,Hz,RongLiangValue,P,Q order by getdate()) as rId from fuhe
) as a where rId=1
2)
delete from fuhe
3)
insert fuhe(KaiGuanDuan,RongLiangPercent,Hz,RongLiangValue,P,Q) select KaiGuanDuan,RongLiangPercent,Hz,RongLiangValue,P,Q from #temp

 

ZC: 完全一样的记录,没有 主键,各个列数据都一样,测试下来 是OK
Oracle删除 字段值完全相同的记录,直留一条:
delete from fuhe a where rowid > (select min(rowid) from fuhe b where a.KaiGuanDuan=b.KaiGuanDuan and a.RongLiangPercent=b.RongLiangPercent and a.hz=b.hz and a.P=b.P and a.Q=b.Q);

 

 

Z

 

Oracle_语句