- Catégories :
IS [ NOT ] NULL¶
Détermine si une expression est NULL ou n’est pas NULL.
Syntaxe¶
<expr> IS [ NOT ] NULL
Renvoie¶
Renvoie BOOLEAN vrai ou faux.
Exemples¶
Créer et charger la table :
CREATE OR REPLACE TABLE i (id NUMBER, col1 NUMBER, col2 NUMBER); INSERT INTO i (id, col1, col2) VALUES (1, 0, 5), (2, 0, null), (3, null, 5), (4, null, null);
Afficher les données :
SELECT * FROM i ORDER BY id; +----+------+------+ | ID | COL1 | COL2 | |----+------+------| | 1 | 0 | 5 | | 2 | 0 | NULL | | 3 | NULL | 5 | | 4 | NULL | NULL | +----+------+------+
Utiliser IS NOT NULL
:
SELECT * FROM i WHERE col1 IS NOT NULL ORDER BY id; +----+------+------+ | ID | COL1 | COL2 | |----+------+------| | 1 | 0 | 5 | | 2 | 0 | NULL | +----+------+------+
Utiliser IS NULL
:
SELECT * FROM i WHERE col2 IS NULL ORDER BY id; +----+------+------+ | ID | COL1 | COL2 | |----+------+------| | 2 | 0 | NULL | | 4 | NULL | NULL | +----+------+------+
Utiliser une combinaison de IS NOT NULL
et IS NULL
:
SELECT * FROM i WHERE col1 IS NOT NULL OR col2 IS NULL ORDER BY id; +----+------+------+ | ID | COL1 | COL2 | |----+------+------| | 1 | 0 | 5 | | 2 | 0 | NULL | | 4 | NULL | NULL | +----+------+------+