ORA-00001: Unique constraint violated
OracleWhat does it mean?
A row being inserted or updated violates a UNIQUE or PRIMARY KEY constraint. In other words, the same value already exists.
Why does it happen?
Re-inserting a row with the same key value, entering duplicate data into a column that must be unique, or processing the same record twice during replication/re-runs.
How to fix it
Find the violated column from the constraint name in the error message: SELECT column_name FROM all_cons_columns WHERE constraint_name = 'CONSTRAINT_NAME'. Use GROUP BY ... HAVING COUNT(*) > 1 to find duplicate data. In the application, use UPDATE or MERGE instead of INSERT for existing records. If the sequence value has fallen behind, advance it with ALTER SEQUENCE.