IS NULL
All functions > COMPARISON > IS NULL
Returns TRUE if the expression evaluates to NULL.
Syntax
expr IS NULL [:: type]
Notes
- Only reliable way to test for NULL values
- Using
= NULLor!= NULLalways returns NULL, not TRUE/FALSE - Works with any data type; optional
::Tafter the keywords disambiguates the expression when its type would otherwise be unclear (for exampleEMPTYfrom an unmatchedRELATED); when::Tis present it must match the expression type (including ARRAY and ROW) - Never returns NULL itself - always Returns TRUE or FALSE
Related Functions
Examples
IS NULL — detection
FeatureQL
SELECT
-- Typed NULL
f1 := NULL::BIGINT IS NULL::BIGINT,
-- Non-NULL literal
f2 := 1 IS NULL::BIGINT
;Result
| f1 BOOLEAN | f2 BOOLEAN |
|---|---|
| true | false |
IS NULL — composite values
FeatureQL
SELECT
-- Typed NULL array
f1 := NULL::ARRAY(BIGINT) IS NULL::ARRAY(BIGINT),
-- Non-NULL array
f2 := ARRAY(1, 2) IS NULL::ARRAY(BIGINT)
;Result
| f1 BOOLEAN | f2 BOOLEAN |
|---|---|
| true | false |
IS NULL — contrast with =
FeatureQL
SELECT
-- `=` cannot test NULL equality
f1 := NULL::BIGINT = NULL::BIGINT
;Result
| f1 BOOLEAN |
|---|
| NULL |