ORA-02437错误:创建表示没有添加主键,当表中存在很多重复数据时,此时再添加主键就会报这个错误。所以,设计表的时候一定要注意!
下面是这个错误的解决办法,先找出表中重复的数据,然后删除相同数据rowid最小的那一列
select *
from xx_table
where xx_no in
(select xx_no from xx_table group by xx_no having count(xx_no) > 1)
delete from xx_table
where xx_no in
(select xx_no from xx_table group by xx_no having count(v) > 1)
and rowid not in (select min(rowid)
from xx_table
group by xx_no
having count(xx_no) > 1)
下面是这个错误的解决办法,先找出表中重复的数据,然后删除相同数据rowid最小的那一列
select *
from xx_table
where xx_no in
(select xx_no from xx_table group by xx_no having count(xx_no) > 1)
delete from xx_table
where xx_no in
(select xx_no from xx_table group by xx_no having count(v) > 1)
and rowid not in (select min(rowid)
from xx_table
group by xx_no
having count(xx_no) > 1)