Today I found an interesting constraint on one of the tables:
alter table T1 add constraint C$T1_DUMMY check (null is null);
Any idea why we need this?
Today I found an interesting constraint on one of the tables:
alter table T1 add constraint C$T1_DUMMY check (null is null);
Any idea why we need this?
The answer is very simple.
The condition null is null
will always return true. Hence the CHECK
statement always returns true and therefore doesn't enforce any additional business logic. Most probably this is why the constraint is named as C$T1_DUMMY
.
I also tried it on my own machine, on the emp
table that comes in Oracle's own sample schema. Works perfectly. Nothing is barred except from syntax errors and other constraints' enforcements.
Possible cases:
One of the meaningful use case would be to check if the running user has privileges to create a constraint on the table.
Exists because it's a tool/script-generated code.
To show more lines of code in his script, of course at the cost of overhead on the table.