Use this one
1.
On the table you want to add primary key,
Alter table tname add constraints pk_tname primary key (col1) disable;
Here 'disable' ensures that the primary key constraint will be created but in a disable status. Thus no error will be reported on primary key conflict.
2.
run $oracle_home\rdbms\admin\utlexcpt.sql to create table 'exceptions'
3.
alter table tname enable primary key exceptions into exceptions
This will record all the conflict rows' rowid into table 'exceptions'
4.
select * from tname where rowid in (select row_id from exceptions)
This statement will return all the rows having conflict.
|