I found a broken check constraint, one that simply wouldn’t work, on a database. It was created as:
|
|
Try it yourself, it doesn’t work! Anyway, I needed to find if there were any other check constraints broken in this manner, so I did the following:
|
|
Of course, that barfed because the SEARCH_CONDITION
column is a LONG
data type. Sigh! I thought those things were deprecated! Never mind, I did this next:
|
|
But the DROP TABLE
command resulted in an error ORA-14452: attempt to create, alter or drop an index on temporary table already in use
. Hmm!
First of all, I had no indexes, so the message is only slightly misleading, but regardless, I couldn’t drop my temporary table when I was finished with it.
The solution is amazingly simple:
|
|
After that, dropping the table “just works”.
And yes, there were quite a few broken check constraints. Duvelopers!
What’s Broken? Well, if you create a check constraint as per the one listed back at the start of this eRant, you will not see any errors from Oracle. Nor will you see any errors when you INSERT
or UPDATE
rows with invalid values in the column. It’s that NULL
thing that kills your constraint. It simply means that any value you have in the column will be accepted.
|
|
Huh? That last one couldn’t have worked, could it?
|
|
Yup, the constraint is indeed useless.
Have fun!