Ternary logic¶
As specified in the SQL standard, ternary logic, or three-valued logic (3VL), is a logic system with three truth values: TRUE, FALSE, and UNKNOWN. In Snowflake, UNKNOWN is represented by NULL. Ternary logic applies to the evaluation of Boolean expressions, as well as predicates, and affects the results of logical operations such as AND, OR, and NOT:
Truth tables¶
This section describes the truth tables for the comparison and logical operators.
Comparison operators¶
If any operand for a comparison operator is NULL, the result is NULL. The comparison operators and functions are:
Logical operators¶
Given a BOOLEAN column C:
If C is: | C AND NULL evaluates to: | C OR NULL evaluates to: | NOT C evaluates to: |
|---|---|---|---|
| TRUE | NULL | TRUE | FALSE |