Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle unique constraint violation referencing a constraint that doesn't seem to exist

I'm receiving an error that I can't make sense of. The error is pretty straightforward:

ORA-00001: unique constraint (*schema*.*xyz_constraint*) violated

However, what's causing my confusion is the fact that no such constraint seems to exist. It's certainly not defined on the table; the DB in question has almost no referential integrity defined, and the particular table into which I'm inserting data has no key defined.

For what it's worth, I can't find the constraint anywhere in the database:

    select *
    from all_constraints 
    where constraint_name like '%xyz_constraint%'

Is there anything I'm overlooking? Thanks.

like image 339
Ickster Avatar asked Jan 17 '12 01:01

Ickster


3 Answers

I had the exact same error and it was not a permissions issue. Rather, the entity turned out to be an INDEX not a CONSTRAINT and I found it with:

SELECT * FROM ALL_INDEXES WHERE INDEX_NAME LIKE '%XYZ_UK1'

...because it did not exist in ALL_CONSTRAINTS or DBA_CONSTRAINTS. Confusing how the error message is the same. I'm running Oracle 11g.

like image 126
Brian Avatar answered Sep 25 '22 19:09

Brian


This happens when the constraint belongs to another user and you don't have permissions to it.

Try looking it once again for now from SYS perspective

like image 30
zerkms Avatar answered Sep 23 '22 19:09

zerkms


Schema object names are almost always stored in upper-case. Try

select *
from all_constraints 
where constraint_name like '%XYZ_CONSTRAINT%'

ORA-00001 usually happens for duplicate primary keys. Are you sure you don't have one on the table?

like image 31
Thilo Avatar answered Sep 25 '22 19:09

Thilo