什么时候“x IS NOT NULL”与“NOT(x IS NULL)”不同
x
是什么
表达式
x IS NOT NULL
is不等于NOT(x IS NULL)
,如2VL中的情况
(引用自 这个答案,引用了Fabian Pascal 数据库管理中的实际问题 - 思考实践者的参考 - 接近答案的结尾)
我的猜测是当 这个猜测是不正确的。x IS NULL
是 NULL,但我无法猜测什么时候会发生(即我没有检查 SQL 标准)。
For what x
is
The expression
x IS NOT NULL
isnot equal toNOT(x IS NULL)
, as is the case in 2VL
(quote from this answer, which is quoting Fabian Pascal Practical Issues in Database Management - A Reference for the Thinking Practitioner -- near the end of that answer)
My guess is when This guess was incorrect.x IS NULL
is NULL, but I cannot guess when that would be (i.e. I haven't checked the SQL standard).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
据我所知,Fabian Pascal 并不是指与 Null 相比的标量值,而是指很少实现的 ROW 类型。在标准中,想法是您可以使用 IS NULL 比较表(行)来确定是否所有值都设置为 NULL 值。因此,
X IS NULL
表示所有值都设置为 NULL 值,X IS NOT NULL
表示没有值设置为 NULL 值,NOT ( X IS NULL)
意味着并非所有值都设置为 NULL 值,或者换句话说,至少存在一个未设置为 NULL 的值。诚然,我在这里轻轻地踩在巨人的肩膀上,但这就是我解释他的声明的方式。From what I've read, Fabian Pascal is not referring to a scalar value in comparison to Null but the rarely implemented ROW type. In the standard, the idea was that you could compare a table (of rows) using
IS NULL
to determine if all values were set to the NULL value. Thus,X IS NULL
would imply all values were set to the NULL value,X IS NOT NULL
would mean no values were set to the NULL value andNOT (X IS NULL)
would mean that not all values were set to the NULL value or, said another way, there existed at least one value not set to NULL. Granted, I'm treading lightly on the shoulders of giants here, but that's how I interpret his statement.x IS NULL
永远不会是NULL
,因此它们对于所有x
都是相同的真值表啊嘿:
请注意,第二列和第四列对于所有
x
都是相同的x
的潜在值(NULL
或NOT NULL
)x IS NULL
will never beNULL
so they are the same for allx
Truth table ahoy:
Note that columns two and four are identical for all potential values of
x
(eitherNULL
orNOT NULL
)