Monday, 11 June 2012

ORA-00001: unique constraint (string.string) violated


ORA-00001: unique constraint (string.string) violated

Cause: An UPDATE or INSERT statement attempted to insert a duplicate key.  For Trusted Oracle configured in DBMS MAC mode, you may see this message if a duplicate entry exists at a different level.

Action: Either remove the unique restriction or do not insert the key.

The options to resolve this Oracle error are:
  1. Drop the unique constraint
  2. Change the constraint to allow duplicate values
  3. Modify your SQL so that a duplicate value is not created
If you are not sure which unique constraint was violated, you can run the following SQL:
select distinct table_name
from all_indexes
where index_name = 'CONSTRAINT_NAME';



In our example (see picture above), our constraint name would be SYS_C002459 and we would execute the following SQL:
select distinct table_name
from all_indexes
where index_name = 'SYS_C002459';
This would return the name of the table whose unique constraint we violated.

No comments:

Post a Comment