零列选择的目的是什么?

时间:2018-02-09 20:58:26

标签: sql postgresql select

这些都是有效的查询:

SELECT;
-- 1 rows affected

SELECT EXCEPT SELECT;
-- 2 rows affected

SELECT 1 WHERE EXISTS (SELECT);
--1


WITH cte AS (VALUES(1),(2))
SELECT 
FROM cte;
--2 rows affected

和DDL:

CREATE TABLE z AS SELECT;

SELECT *
FROM information_schema.columns
WHERE table_name = 'z';
-- empty

SELECT attrelid::regclass AS tbl
     , attname            AS col
     , atttypid::regtype  AS datatype
FROM   pg_attribute
WHERE  attrelid = 'z'::regclass
ORDER  BY attnum;
-- internal columns

DBFiddle Demo

我想知道可以使用零列选择(现实场景),或者只是PostgreSQL语言扩展/语法怪癖。

0 个答案:

没有答案