When I was trying to add constraint of primary key on existing table with some data i was getting following error:
ORA-02437: cannot validate- primary key violated
Later i realize the error was due to duplicate entries in the column to be assigned as primary key. Then i executed following syntax to find duplicate entries for modification:
Syntax 1:
select column_name, count(column_name)
from table
group by column_name
having count (column_name) > 1;
Syntax 2:
select my_id, count(*) from my_table group by my_id having count(*) >1
No comments:
Post a Comment