Database SQL Boolean Column

Home » SQL » Database SQL Boolean Column
SQL No Comments

A boolean column can have either of the 3 values: true, false or null (unknown).

It is a good idea to ALWAYS define a boolean column as “NOT NULL” thus restricting it to either true or false only.

The following query highlights the potential issue with null (unknown) value:

mycol != TRUE

This statement is only true if mycol has a “false” value. To cater for null value we have to do this:

(mycol is null or mycol != TRUE)