SQL ANY和SOME关键字是否在所有SQL方言中都是同义词? [英] Are SQL ANY and SOME keywords synonyms in all SQL dialects?

查看:178
本文介绍了SQL ANY和SOME关键字是否在所有SQL方言中都是同义词?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Postgres中,当在谓词表达式的右侧使用时,ANYSOME是同义词.例如,它们是相同的:

In Postgres, ANY and SOME are synonyms when used on the right hand side of a predicate expression. For example, these are the same:

column = ANY (SELECT ...)
column = SOME (SELECT ...)

在此处记录:

http://www .postgresql.org/docs/9.1/static/functions-subquery.html#FUNCTIONS-SUBQUERY-ANY-SOME

我观察到ANYSOME至少受以下SQL DBMS支持:

I have observed ANY and SOME to be supported by at least these SQL DBMSs:

  • DB2
  • 德比
  • H2
  • HSQLDB
  • Ingres
  • MySQL
  • Oracle
  • Postgres
  • SQL Server
  • Sybase ASE
  • Sybase SQL Anywhere
  • DB2
  • Derby
  • H2
  • HSQLDB
  • Ingres
  • MySQL
  • Oracle
  • Postgres
  • SQL Server
  • Sybase ASE
  • Sybase SQL Anywhere

我是否可以安全地假设所有这些方言(以及其他方言)都将ANYSOME视为同义词,或者在任何/某些DBMS中这两个关键字之间是否存在细微差别?

Can I safely assume that all of those dialects (and others, too) treat ANY and SOME as synonyms or is there a subtle difference between the two keywords in any/some DBMS?

我在SQL92定义中发现了这一点:

I have found this in the SQL92 definition:

<quantifier> ::= <all> | <some>
<all> ::= ALL
<some> ::= SOME | ANY

这没有说明ANYSOME的语义.在文档的后面,仅引用<some>,而不引用两个关键字.我怀疑至少在某些DBMS中NULL处理可能存在细微差别.欢迎任何/某些指向明确声明的指针,无论是否可以假设.

This doesn't say anything about the semantics of ANY and SOME. Later on in the document, only <some> is referenced, not the two keywords. I'm suspecting that there might be a subtle difference in NULL handling, for instance, at least in some DBMSs. Any/some pointer to a clear statement whether this can be assumed or not is welcome.

推荐答案

引用后几行,SQL92标准还指定了<some>的语义,即:

Few lines after what you're quoting, the SQL92 standard also specifies the semantics for <some>, namely:

c) If the implied <comparison predicate> is true for at least
one row RT in T, then "R <comp op> <some> T" is true.

d) If T is empty or if the implied <comparison predicate> is
false for every row RT in T, then "R <comp op> <some> T" is
false.

e) If "R <comp op> <quantifier> T" is neither true nor false,
then it is unknown.

这些规则适用于<some>令牌,而与它是SOME还是ANY替代方案无关,所以是的,根据标准它们是同义词

These rules apply for the <some> token, independent on whether it is the SOME or ANY alternative, so yes, they are synonyms according to the standard

这篇关于SQL ANY和SOME关键字是否在所有SQL方言中都是同义词?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆