我意外地写了一个像my_table中选择的查询;而且令人惊讶的是它是有效的声明.对我来说更有趣的是即使是SELECT;是Postgresql中的有效查询.您可以尝试用以下方法编写很多有趣的查询:
select union all select; with t as (select) select; select from (select) a,(select) b; select where exists (select); create table a (b int); with t as (select) insert into a (select from t);
这是一些定义sql标准的结果,还是有一些用例,或者只是有趣的行为,没有人关心以编程方式限制?
Right from the manual:
原文链接:https://www.f2er.com/postgresql/192213.htmlThe list of output expressions after
SELECT
can be empty,producing a zero-column result table. This is not valid Syntax according to the sql standard. Postgresql allows it to be consistent with allowing zero-column tables. However,an empty list is not allowed whenDISTINCT
is used.
如果我没有弄错的话,“零列”表的可能性是表继承的副作用.关于Postgres邮件列表的讨论(但我现在找不到)