You can use the EXCEPTIONS INTO clause to catch duplicate rows.
If you do not have an EXCLUSION table yet, create it using the provided script:
SQL> @$ORACLE_HOME/rdbms/admin/ultexcpt.sql
Now you can try to create a unique constraint like this
alter table Table1 add constraint tab1_uq UNIQUE (col1, col2, col3, col4) exceptions into exceptions /
This will result in an error, but now your EXCEPTIONS table contains a list of all rows whose keys contain duplicates identified by ROWID. This gives you a basis for deciding what to do with duplicates (delete, renumber, whatever).
change
As already noted, you have to pay the cost of scanning the table once. This approach gives you a constant set of duplicate rows, and ROWID is the fastest way to access any given row.
APC
source share