没有返回任何行时的ANY和ALL

时间:2016-04-08 09:18:22

标签: oracle oracle11g oracle10g oracle12c

Oracle

If a subquery returns zero rows, 
the condition [operator]ANY[subquery] evaluates to FALSE
the condition [operator]ALL[subquery] evaluates to TRUE

它基于哪个布尔逻辑或逻辑数学?

1 个答案:

答案 0 :(得分:1)

没有什么不寻常之处 - 它只是实现了数学的All and Exists运算符,其定义是(以外行人的名义)

给定一个M和一个谓词p,然后

All m elem M (p) 
<=> each element of M satisfies the predicate p 
<=> there's no element in M that doesn't satisfy p

显然,对于空集合,情况确实如此,因为它根本不包含任何元素。

给定一个M和一个谓词p,然后

Any m elem M (p) 
<=> there exists at least one element of M that satisfies the predicate p 
<=> for all elements of M, the inverse predicate !p is false

显然,对于空集合来说这是错误的,因为它根本不包含任何元素,因此不至少有一个元素满足谓词。它也很好地补充了All(m)的定义,因为

All(p) <=> !Any(!p)

其中!表示逻辑逆NOT。

相关问题