Check constraint without columns

Today I found an interesting limitation for one of the tables:

alter table T1 add constraint C$T1_DUMMY check (null is null); 

Any idea why we need this?

+4
source share
1 answer

The answer is very simple.

The condition null is null will always return true. Therefore, the CHECK operator always returns true and, therefore, does not apply any additional business logic. Most likely, this is why the restriction is called C$T1_DUMMY .

I also tried this on my machine, in the emp table, which comes in Oracle's own instance scheme. Works great. Nothing is forbidden except from syntax errors and other coercive measures of restrictions.

0
source

All Articles