ZKX's LAB

Oracle如何删除一张表内的重复数据,但保留最新的一条? oracle 删除表重复数据

2021-04-07知识0

ORACLE 删除重复数据 我的已经试过了,【行】。删除相同行(除主键外,其它属性值相同的行),举个例子给你看看吧。delete from dept a where a.deptnoselect min(deptno)from dept t group by(dname,loc)having count(*)>;1 and a.dname=t.dname and a.loc=t.loc其中,dept的主键是deptno,针对(dname,loc)这两个属性值相同的行,把重复的删除,留下deptno值最小的那一行。你的表主键是user_id吧,重复的属性值是(company_id,fee_date,insure_id)吧,你的可以改成以下:delete from t_insure_feed a where a.user_idselect min(user_id)from t_insure_feed t group by(company_id,fee_date,insure_id)having count(*)>;1 and a.company_id=t.company_id and a.fee_date=t.fee_date and a.insure_id=t.insure_id你建的表没有主键?也许你的表没。直接试一下第3条吧。不给我红旗就不跟你玩了。3.可以新创建一张表,该表装载没有重复的行create table mytemp asselect user_id,company_id,fee_date,insure_id/*列出所有的列*/from t_insure_feed group by(user_id,company_id,fee_date,insure_id/*列出所有的列*/);查询:select*from mytemp;1.查询重复(usr_id)的行:select 。

oracle数据库中怎样删除一个表的重复数据。 这个问题就是要删除表中重复的记录,查询的sql语句如下:select id,name from(select id,name,row_numer()over(partition by id,name order by id,name)rn from tableA)。

Oracle如何删除一张表内的重复数据,但保留最新的一条? 楼主你的这个SQL会将表中所有重复的数据都给删掉的,包括你要保留的最新的时间戳的数据。其实你的这个SQL知识查询出来的那些数据是重复的,至于要删除那条数据,你的这个SQL定位不到。查询出你想要删除的重复数据用下面的SQL:select*from table a where a.createdate<;(select max(b.createdate)from table b where a.customer_guid=b.customer_guid);删除的话就用这个了:delete from table a where a.createdate<;(select max(b.createdate)from table b where a.customer_guid=b.customer_guid);

随机阅读

qrcode
访问手机版