Does SQL standard allows whitespace between function names and parenthesis

霸气de小男生 提交于 2019-12-12 11:38:47

问题


Checking few RDBMS I find that things like

SELECT COUNT (a), SUM (b)  
FROM TABLE

are allowed (notice space between aggregate functions and parenthesis).

Could anyone provide a pointer to SQL standard itself where this is defined (any version will do)?

EDIT: The above works in postgres, mysql needs set sql_mode = "IGNORE_SPACE"; as defined here (for full list of functions that are influenced with this server mode see in this ref). MS SQL is reported to accept the above.

Also, it seems that the answer is most likely in the standard. I can follow the BNF regarding the regular symbols and terms, but I get lost when it comes to the definition of whitespace and separators in that part of the select.


回答1:


Yes; the white space between tokens is substantially ignored. The only exception is, officially, with adjacent string literal concatenation - but the standard is weirder than any implementation would be.

See: http://savage.net.au/SQL/




回答2:


This works in SQL Server 2005:

SELECT COUNT   (*)
  FROM TABLE

...while one space between COUNT and (*) on MySQL causes a MySQL 1064 error (syntax error). I don't have Oracle or Postgres handy to test.

Whatever the standard may be, it's dependent on implementation in the vendor and version you are using.




回答3:


I can't provide a pointer, but I believe that white space like that is ignored.

I know that it is in T-SQL, and about 80% certain about MySQL's implementation.



来源:https://stackoverflow.com/questions/2501704/does-sql-standard-allows-whitespace-between-function-names-and-parenthesis

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!