关于ansi_nulls [英] something about ansi_nulls
问题描述
我有一个问题,我们总是说null = null为false,我想知道当ansi_nulls关闭时,这条"null = null"也是假的吗?谢谢
I have a question that we always say that null =null is false ,I want to know that when the ansi_nulls is off this statement which is "null=null" is also false? thanks
推荐答案
对于ANSI_NULLS OFF
,NULL = NULL
的值为TRUE
.
对于ANSI_NULLS ON
(默认值),NULL = NULL
的计算结果为NULL
.
With ANSI_NULLS ON
(the default), NULL = NULL
evaluates to NULL
.
NULL IS NULL
总是计算为TRUE
.
但是,在MySQL中,您不能关闭ANSI_NULLS.您可能正在考虑MS SQL Server.
However, in MySQL, you cannot turn off ANSI_NULLS. You are probably thinking of MS SQL Server.
未来版本的MS SQL Server将不支持ANSI_NULLS OFF
,所以我不会使用它.
Future versions of MS SQL Server won't support ANSI_NULLS OFF
, so I wouldn't use it.
您应该离开ANSI_NULLS ON
并使用IS NULL
来评估某些内容是否为空.
You should leave ANSI_NULLS ON
and use IS NULL
to evaluate if something IS NULL.
如果您在记住默认情况下NULL的工作方式时遇到了问题(ANSI_NULLS ON),则应将NULL视为"未知".例如,如果房间里有两个陌生人,他们的名字就是NULL.如果您的查询是它们的名称相同吗?"您的答案为空.
If you're having problems remembering how NULL works by default (ANSI_NULLS ON), you should think of NULL as "unknown". For example, if there are two strangers in the room, their names are NULL. If your query is, "Are their names the same?" Your answer IS NULL.
现在,假设鲍勃在房间里只有一个陌生人,名字叫空.再次回答您的查询它们的名称相同吗?"一片空白.请注意,如果您将任何内容与NULL进行比较,则答案为NULL.
Now, let's say Bob is in the room with just one stranger, whose name IS NULL. Again the answer to your query "Are their names the same?" IS NULL. Note that if you compare anything to NULL, your answer IS NULL.
这篇关于关于ansi_nulls的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!