加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

postgresql – 为什么没有列的SELECT有效

发布时间:2020-12-13 16:19:41 所属栏目:百科 来源:网络整理
导读:我意外地写了一个像my_table中选择的查询;而且令人惊讶的是它是有效的声明.对我来说更有趣的是即使是SELECT;是PostgreSQL中的有效查询.您可以尝试用以下方法编写很多有趣的查询: select union all select;with t as (select) select;select from (select) a
我意外地写了一个像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:

The 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 when DISTINCT is used.

如果我没有弄错的话,“零列”表的可能性是表继承的副作用.关于Postgres邮件列表的讨论(但我现在找不到)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读