public inbox for [email protected]
help / color / mirror / Atom feedFrom: David G. Johnston <[email protected]>
To: Amir Rohan <[email protected]>
Cc: [email protected] <[email protected]>
Subject: Re: Docs claim that "select myTable.*" wildcard won't let you assign column names
Date: Mon, 21 Sep 2015 21:58:58 -0400
Message-ID: <CAKFQuwagxbGTVji92nQ5a10u8gPK2THwG55Zh3yy-MYRCa=9dA@mail.gmail.com> (raw)
In-Reply-To: <trinity-ff5523c7-87b0-4409-ab20-83a3b5b172f8-1442883892582@3capp-mailcom-lxa13>
References: <trinity-f7a55438-da76-471a-8b06-b5446f01918b-1442875052542@3capp-mailcom-lxa10>
<CAKFQuwb1pTAh3gGzReSnUAoSobYQmHhy-90rKo82BeVCR7W+Kw@mail.gmail.com>
<trinity-ff5523c7-87b0-4409-ab20-83a3b5b172f8-1442883892582@3capp-mailcom-lxa13>
List-Unsubscribe: <mailto:[email protected]?body=unsub%20pgsql-docs>
On Monday, September 21, 2015, Amir Rohan <[email protected]> wrote:
> On Monday, September 21, 2015, Amir Rohan <[email protected]
> <javascript:;>> wrote:
>
>
> >> From
> http://www.postgresql.org/docs/9.4/static/sql-select.html[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) ;<...>
>
> On Monday, September 21, 2015, David G. Johnston wrote:
>
> > Neither of those examples is:
> >
> > SELECT * AS "how would one alias this?" FROM table
> >
> > So what's your point?
>
> My point is that "In these cases it is not possible to specify new names
> with AS" is misleading because
> it *is* possible and useful, but requires syntax which isn't clearly shown
> (if at all) where I'd expect it.
> I think that could be improved.
>
> > Obviously you can alias stuff before it makes its way into a select-list
> that refers to it using *
>
> "obvious" to whom? probably not to someone who's level of SQL mastery has
> brought him/her to reading
> the exciting "SELECT" documentation. I do see your point though, in the
> grammar the "AS" in my example
> belongs not to `output_name ` but to `from_item`. So this syntax is hidden
> away behind the `column_alias`
> production.
>
> > In this case the FROM clause is what is being aliased. It is documented
> though I'd need to look to
> > identify the specific location.
>
> This belongs in the page describing SELECT, and though I've looked I
> haven't found it. If I'm wrong (
> I did look again just now), please correct me.
>
>
To be honest, if you have a situation where you think you need to alias "*"
you should probably be expanding that "*" out into individual column names
anyway, which you can easily alias.
The docs don't make a big deal of alising other than noting individually
where they can happen (cte, from clause, select-list) and few questions
that are raised are probably better served to be simply handled on these
lists than cluttering the docs.
David J.
view thread (6+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: Docs claim that "select myTable.*" wildcard won't let you assign column names
In-Reply-To: <CAKFQuwagxbGTVji92nQ5a10u8gPK2THwG55Zh3yy-MYRCa=9dA@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox