Re: "SELECT FROM foo" acts like "SELECT COUNT(*) FROM foo"?

Поиск
Список
Период
Сортировка
Искать
От
Tom Lane
Тема
Re: "SELECT FROM foo" acts like "SELECT COUNT(*) FROM foo"?
Дата
Msg-id
1409990.1675282221@sss.pgh.pa.us
Ответ на
Список
Дерево обсуждения
"SELECT FROM foo" acts like "SELECT COUNT(*) FROM foo"? Ron <ronljohnsonjr@gmail.com>
Re: "SELECT FROM foo" acts like "SELECT COUNT(*) FROM foo"? Tom Lane <tgl@sss.pgh.pa.us>
Re: "SELECT FROM foo" acts like "SELECT COUNT(*) FROM foo"? Rodrigo Luna <rodrigomrluna78@gmail.com>
Re: "SELECT FROM foo" acts like "SELECT COUNT(*) FROM foo"? "David G. Johnston" <david.g.johnston@gmail.com>
Re: "SELECT FROM foo" acts like "SELECT COUNT(*) FROM foo"? "David G. Johnston" <david.g.johnston@gmail.com>
Ron  writes:
> v12.13
> https://www.postgresql.org/docs/12/sql-select.html

> The docs say that one of these are required in the SELECT list.

> [ * |/|expression|/  [ [ AS ]/|output_name|/  ] [, ...] ]

Really?  I don't see anything to that effect in either the syntax
synopsis or the text, plus there's this in the Compatibility section:

    Empty SELECT Lists

    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.

We probably did say that before 9.4 or so, but if you still find it
in modern releases, please say exactly where.

> However, *not* mentioning anything also works, though acts like COUNT(*).

Well, you get some number of zero-column rows.  psql's display of that is
a bit idiosyncratic, but nobody's bothered to improve it.

			regards, tom lane


В списке pgsql-general по дате отправления
От: David G. Johnston
Дата:
От: Siddharth Jain
Дата:
FAQ