On Monday, September 21, 2015, Amir Rohan <amir.rohan@mail.com> wrote:
From http://www.postgresql.org/docs/9.4/static/sql-select.html (and previous version too):##SELECT List
<...>Instead of an expression, * can be written in the output list as a shorthand for all the columns of the selected rows.Also, you can write table_name.* as a shorthand for the columns coming from just that table. In these cases it is notpossible to specify new names with AS; the output column names will be the same as the table columns' names.But, the docs elsewhere feature a query example show the use of a wildcard for columnsas well as allowing you to assign names to as many of the leading columns as you wish:WITH T0 as ( SELECT 1,2,3 )
SELECT T0.* from T0 as T0(foo,bar) ;foo │ bar │ ?column?
─────┼─────┼──────────
1 │ 2 │ 3
(1 row)The following curious variant also works:WITH T0 as ( SELECT 1,2,3 )
SELECT justAnythingReally.* from T0 as justAnythingReally(foo,bar) ;The synoposis/grammer at the top doesn't hint at this either. I've checked and this has been supported since at least 9.2 .