删除
delete from cxtx.ka_gpsdata a where rowid<(select max(rowid) from cxtx.ka_gpsdata where vid=a.vid and gps_time=a.gps_time)
然后马上添加约束
alter table cxtx.ka_gpsdata add constraint uk_mayunlong unique(vid,gps_time)
但总是报错
ora 02299 : 无法验证(CXTX.UK_MANYUNLONG) - 未能找到重复关键字
4 个解决方案
#1
group by vid,gps_time having count(*)>1
试试
试试
#2
1楼的意思是我没有把重复记录删掉吗?
#3
我晕啊,换了好几个版块,都没有人回答啊
#4
--如果有,先删除约束
alter table ka_gpsdata drop constraint uk_mayunlong
select * from ka_gpsdata t where exists(
select 1 from ka_gpsdata where checksum(vid,gps_time)=checksum(vid,gps_time)
group by vid,gps_time having count(1)>1)
--把上面查到的记录删除
--新键约束
alter table cxtx.ka_gpsdata add constraint uk_mayunlong unique(vid,gps_time)
#1
group by vid,gps_time having count(*)>1
试试
试试
#2
1楼的意思是我没有把重复记录删掉吗?
#3
我晕啊,换了好几个版块,都没有人回答啊
#4
--如果有,先删除约束
alter table ka_gpsdata drop constraint uk_mayunlong
select * from ka_gpsdata t where exists(
select 1 from ka_gpsdata where checksum(vid,gps_time)=checksum(vid,gps_time)
group by vid,gps_time having count(1)>1)
--把上面查到的记录删除
--新键约束
alter table cxtx.ka_gpsdata add constraint uk_mayunlong unique(vid,gps_time)