Mohamed Houri’s Oracle Notes

March 21, 2013

ORA-02431: Cannot disable constraint

Filed under: Trouble shooting — hourim @ 7:21 pm

Recently a question came up on the otn forum which reminded me to write a small blog article that I will be referring to instead of creating a different test each time I see people asking how to trouble shoot the same error as that mentioned by the Original Poster(OP). The OP was struggling about an existing constraint which, despite he is seeing it via a select against user_constraints table, he, nevertheless, was unable to disable it because of ORA-02431 error: cannot disable constraint FK_Batch_Products no such constraint.
Here below is the select against the OP user_constraints table:

CONSTRAINT_NAME             CONSTRAINT_TYPE      STATUS
--------------------------- ------------------ -----------
FK_Product_SourceSpecies    R                  ENABLED
FK_Product_CreatePerson     R                  ENABLED
FK_Product_ModifyPerson     R                  ENABLED
FK_Product_ExpressionSystem R                  ENABLED
FK_Product_Localisation     R                  ENABLED
FK_Batch_Products           R                  ENABLED

Have you already spotted the obvious?

Well if not then let me tell you one thing:  each time I see lowercase letters in an Oracle object names then I am hundred percent sure that the owner of this object will have trouble identifying those objects and I will not be surprised when he will be faced to such a kind of non existing object error.

Below I have modeled the problem and have shown the solution to the OP.

SQL> create table t (id number, vc varchar2(10));

Table created.

SQL> alter table t add constraint t_pk primary key (id);

Table altered.

SQL> alter table t add constraint "t_lower_case" check (vc != 'NONE');

Table altered.

SQL> select table_name, constraint_name
  2  from user_constraints
  3  where table_name = 'T';

TABLE_NAME                     CONSTRAINT_NAME
------------------------------ ------------------------------
T                              T_PK
T                              t_lower_case

SQL> alter table t drop constraint t_lower_case;
alter table t drop constraint t_lower_case
                              *
ERROR at line 1:
ORA-02443: Cannot drop constraint  - nonexistent constraint

SQL> alter table t drop constraint "t_lower_case";

Table altered.

Bottom Line : it is very important to be careful when creating Oracle objects; give  them correct naming standard without enclosing their names between double quotes i.e. “ “

2 Comments »

  1. Mohamed, it may be a tool that did this, rather than the developer himself.
    (Still wrong though). 😉

    Comment by Martin Rose — March 21, 2013 @ 10:11 pm | Reply

  2. Martin,

    Very often, if not always, I forget that “tool” or “ERP’’ automatic generated code. Thanks for spotting that to me

    Cheers

    Comment by Houri — March 22, 2013 @ 7:38 am | Reply


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

Tony's Oracle Tips

Tony Hasler's light hearted approach to learning about Oracle

Richard Foote's Oracle Blog

Focusing Specifically On Oracle Indexes, Database Administration and Some Great Music

Hatem Mahmoud Oracle's blog

Just another Oracle blog : Database topics and techniques

Mohamed Houri’s Oracle Notes

Qui se conçoit bien s’énonce clairement

Oracle Diagnostician

Performance troubleshooting as exact science

Raheel's Blog

Things I have learnt as Oracle DBA

Coskan's Approach to Oracle

What I learned about Oracle

So Many Oracle Manuals, So Little Time

“Books to the ceiling, Books to the sky, My pile of books is a mile high. How I love them! How I need them! I'll have a long beard by the time I read them”—Lobel, Arnold. Whiskers and Rhymes. William Morrow & Co, 1988.

EU Careers info

Your career in the European Union

Carlos Sierra's Tools and Tips

Tools and Tips for Oracle Performance and SQL Tuning

Oracle Scratchpad

Just another Oracle weblog

OraStory

Dominic Brooks on Oracle Performance, Tuning, Data Quality & Sensible Design ... (Now with added Sets Appeal)

%d bloggers like this: