在“group by”之前缺少空格,但仍然是有效的psql查询

时间:2015-01-20 14:33:35

标签: whitespace psql

有人可以解释为什么这个psql查询有效:

select count(*) from employee where accountid=9group by companyid;

1 个答案:

答案 0 :(得分:0)

SQL-92 BNF Grammar here明确指出 delimiters (bracket, whitespace, * etc) are valid to break up the tokens ,这使得在其他分隔符已经分解标记的各种情况下,空格可选。

<强> Whitespace is optional in pretty much any language where it is not absolutely necessary to preserve boundaries between keywords and/or identifiers 即可。您可以使用与SQL类似的C#编写代码,只要编译器仍然可以解析标识符和关键字,它就不会关心。