Oracle SQL Syntax - Check multiple columns for IS NOT NULL Oracle SQL Syntax - Check multiple columns for IS NOT NULL oracle oracle

Oracle SQL Syntax - Check multiple columns for IS NOT NULL


With De Morgan's law:

NOT (A OR B) = (NOT A) AND (NOT B)

you save 20 chars ;)

NOT (weight IS NULL ORweight_unit IS NULL ORlength IS NULL ORwidth IS NULL ORheight IS NULL ORdimensional_unit IS NULL )


As far as I know, there isn't such a syntax.

But if all of them are numeric you can use this trick:

weight + weight_unit + length + width + height + dimensional_unit is not null


ALTER TABLE X   ADD CONSTRAINT C_X_NN      CHECK (  (               DECODE (weight, NULL, 0, 1) +               DECODE (weight_unit, NULL, 0, 1) +               DECODE (length      , NULL, 0, 1) +               DECODE (width     , NULL, 0, 1) +               DECODE (height      , NULL, 0, 1) +               DECODE (dimensional_unit , NULL, 0, 1)               ) = 0            );