何时可以使用语法WHERE IS ....和Where .. = ..
我看到一些帖子说Null只能与IS一起使用,但还有什么可以与IS一起使用?
预先感谢
答案 0 :(得分:2)
在标准SQL中,除了IS [NOT] NULL
之外,还有几个基于IS
的谓词,请参见SQL 2016 BNF syntax
6.39 <boolean value expression> Function
Specify a boolean value.
...
<boolean test> ::=
<boolean primary> [ IS [ NOT ] <truth value> ]
<truth value> ::=
TRUE
| FALSE
| UNKNOWN
8.12 <normalized predicate> Function
Determine whether a character string value is normalized. Format
<normalized predicate> ::= <row value predicand> <normalized predicate part 2>
<normalized predicate part 2> ::= IS [ NOT ] [ <normal form> ] NORMALIZED
8.15 <distinct predicate> Function
Specify a test of whether two row values are distinct Format
<distinct predicate> ::= <row value predicand 3> <distinct predicate part 2>
<distinct predicate part 2> ::= IS [ NOT ] DISTINCT FROM <row value predicand 4>
8.18 <set predicate>
Function
Specify a test of whether a multiset is a set (that is, does not contain any duplicates).
Format
<set predicate> ::=
<row value predicand> <set predicate part 2>
<set predicate part 2> ::=
IS [ NOT ] A SET
8.19 <type predicate>
Function
Specify a type test.
Format
<type predicate> ::=
<row value predicand> <type predicate part 2>
<type predicate part 2> ::=
IS [ NOT ] OF <left paren> <type list> <right paren>
8.22 <JSON predicate>
Function
Test whether a string value is a JSON text.
Format
<JSON predicate> ::=
<string value expression> [ <JSON input clause> ]
IS [ NOT ] JSON
[ <JSON predicate type constraint> ]
[ <JSON key uniqueness constraint> ]
但是DBMS支持通常很少,例如PostgreSQL支持 boolean / type / distinct 谓词(可能比其他谓词更多)