Re: Docs claim that "select myTable.*" wildcard won't let you assign column names

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Amir Rohan <amir(dot)rohan(at)mail(dot)com>
Cc: "pgsql-docs(at)postgresql(dot)org" <pgsql-docs(at)postgresql(dot)org>
Subject: Re: Docs claim that "select myTable.*" wildcard won't let you assign column names
Date: 2015-09-21 23:39:38
Message-ID: CAKFQuwb1pTAh3gGzReSnUAoSobYQmHhy-90rKo82BeVCR7W+Kw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

On Monday, September 21, 2015, Amir Rohan <amir(dot)rohan(at)mail(dot)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 not
> possible 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 columns
> as 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 .
>
>

Neither of those examples is:

SELECT * AS "how would one alias this?" FROM table

So what's your point? Obviously you can alias stuff before it makes its
way into a select-list that refers to it using *

In this case the FROM clause is what is being alised. It is documented
though I'd need to look to identify the specific location. It would not be
documented in a section regarding the select-list.

David J.

In response to

Responses

Browse pgsql-docs by date

  From Date Subject
Next Message Amir Rohan 2015-09-22 01:04:53 Re: Docs claim that "select myTable.*" wildcard won't let you assign column names
Previous Message Amir Rohan 2015-09-21 22:37:33 Docs claim that "select myTable.*" wildcard won't let you assign column names