SQL标准规定中null值判断是否合理?
妙音
posted @ 2014年2月11日 18:50
in 数据库
with tags
sql;postgres
, 1800 阅读
在postgres中判断null值时,下面语句的结果不相等,为什么?
select * from user_info where user_name is null select * from user_info where user_name = null
原因是postgres遵循sql标准,在ANSI SQL(SQL-92)标准中规定的Null值的比较取值结果都为False.
它认为NULL 代表一个未知的数值,无法知道两个未知的数值是否相等。
这个理由很不充分,既然无法判断,那么is null又是如何判断它是空的呢?
虽然null表面含义是未知值,但是计算机中不可能有不确定的表示. 常见程序语言中null实际都是一个特殊值,一个确定的特殊值。所以在编程语言中是允许使用null=null(值比较)的. SQL中不允许是否合理?
2021年1月04日 19:13
Im no expert, but I believe you just made an excellent point. You certainly fully understand what youre speaking about, and I can truly get behind that. movies123 app
2021年1月09日 22:33
Someone Sometimes with visits your blog regularly and recommended it in my experience to read as well. The way of writing is excellent and also the content is top-notch. Thanks for that insight you provide the readers! 토토사이트