From amir.rohan@mail.com Sun May 24 04:56:36 2026 Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Ze9iM-0001y7-Tp for pgsql-docs@arkaria.postgresql.org; Mon, 21 Sep 2015 22:37:39 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1Ze9iM-0003hR-64 for pgsql-docs@arkaria.postgresql.org; Mon, 21 Sep 2015 22:37:38 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1Ze9iL-0003gx-7c for pgsql-docs@postgresql.org; Mon, 21 Sep 2015 22:37:37 +0000 Received: from mout.gmx.com ([74.208.4.200]) by makus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.84) (envelope-from ) id 1Ze9iI-00060n-J1 for pgsql-docs@postgresql.org; Mon, 21 Sep 2015 22:37:35 +0000 Received: from [5.102.207.29] by 3capp-mailcom-lxa10.server.lan (via HTTP); Tue, 22 Sep 2015 00:37:33 +0200 MIME-Version: 1.0 Message-ID: From: "Amir Rohan" To: pgsql-docs@postgresql.org Subject: Docs claim that "select myTable.*" wildcard won't let you assign column names Content-Type: text/html; charset=UTF-8 Date: Tue, 22 Sep 2015 00:37:33 +0200 Importance: normal Sensitivity: Normal X-Priority: 3 X-Provags-ID: V03:K0:UVL9bs1QAm9F+P+2p9mQIywczfyEBpOBI1QDAXRSKKW dciDsUidkgx2w5oUYSBeC/YvPNN55hm0Q45VuCraUIgYtOHOD+ NGawmSuLh9n6Gv6Z4UDbtacHKwl8HanuNwIieHPqd/lR7Pgj59 Fhq0Cti9v0yxHlosZpE4/p9fErpl+UFnHlt7Vz6cZR6fAScrCv kVNg51LGpVPWamhzZtzI6Hc/Q0OnPZemDXqFXpZ9TTfa+ruLfv Rlil2W8yZBIad3yJAazAsqmBFdkdEyGZAHqhwqxOx9VMLSOt1O +IMs+s8HvKMFHzWL6rOAWZps8Ml X-UI-Out-Filterresults: notjunk:1;V01:K0:0Uj32fRebZw=:3un1JJsa1ZgHFVamke+rH7 Mkf+hSOUJJvNyt/8X0bwgJaAukaemjzyJlxcq8YCM7/5dTWJf78QxxkabEAApbAUZS0ndb9/j 0ppTreuOomdDmoZSLTX8gkKZFHEQ26LXbbCOMxiGyUxuZihmtSZXe2WS1bthOlJlfR+bJWGji xR9FW1hs92zDSLPvCEJRRibPasiNhx24lSFb49swJawVlTRj/ZvYJoHqfn8UYylbNQY6yxsc6 Mu3ICLVRwp+KNV+Vr7IR5YVwRrKu3OcU5BTz17IzeOvxzMWMnekBoo0YTsZCw1B8SbdlmbEOL JdiVEOqi9h22Nbthofzs63E2gKbXeh9BRXzkL0+0ywsQuAVc3aPZxSRs08foT0CLku4UN05q6 2qPMrf3nyuUX1VbTjji8wwlF+iKFqNeniT2m0hM16F9GWpb17IIyjiDfbHTbHei5aqpqVEjMY anW1uAqB1A== X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-docs Precedence: bulk Sender: pgsql-docs-owner@postgresql.org
 
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 .
 
Regards,
Amir
 
From david.g.johnston@gmail.com Sun May 24 04:56:36 2026 Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZeAga-0004O7-BG for pgsql-docs@arkaria.postgresql.org; Mon, 21 Sep 2015 23:39:52 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZeAgY-0005De-FF for pgsql-docs@arkaria.postgresql.org; Mon, 21 Sep 2015 23:39:50 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZeAgX-0005D7-GZ for pgsql-docs@postgresql.org; Mon, 21 Sep 2015 23:39:49 +0000 Received: from mail-io0-x22c.google.com ([2607:f8b0:4001:c06::22c]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1ZeAgP-0004U3-NK for pgsql-docs@postgresql.org; Mon, 21 Sep 2015 23:39:48 +0000 Received: by iofb144 with SMTP id b144so455201iof.1 for ; Mon, 21 Sep 2015 16:39:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=W1sranl7IRC4OhySHWD1dHIFlnxfsneNAMdC0D65DHE=; b=VsBn3Rep6m1twa4s28sQLd7CAB+nV/O9Q/GrRvySMhscOij5vzXsRciK4hJxoq8DXR ib0hzNKlWqcgAT72WYNESzMRSj6UUlSbuSaF2OlQNKbqEDdxGc6dzg+r6N+T8acx9HnY 6TyIBIaU3tK9QaPp7BO80BfwXeafNJmnZvmzHTDNY5gJcTmySukkLRyerryPCIIhHMwA RrEyK02kE1F+G5IPFYabVXfW8Afyg76+PmMqNsZZUYjwv+GvySOgyW1Kwd90O6K/ss/e z1pbH6+mW2Ig//0+0S5wyecJK/eoyNFwizlu9JwWVF0EPwjQ+/c9ZoYCeBPsT/BgO+VZ urMw== MIME-Version: 1.0 X-Received: by 10.107.161.144 with SMTP id k138mr32313011ioe.47.1442878778681; Mon, 21 Sep 2015 16:39:38 -0700 (PDT) Received: by 10.36.143.141 with HTTP; Mon, 21 Sep 2015 16:39:38 -0700 (PDT) In-Reply-To: References: Date: Mon, 21 Sep 2015 19:39:38 -0400 Message-ID: Subject: Re: Docs claim that "select myTable.*" wildcard won't let you assign column names From: "David G. Johnston" To: Amir Rohan Cc: "pgsql-docs@postgresql.org" Content-Type: multipart/alternative; boundary=001a1140faa80eb02405204a6507 X-Pg-Spam-Score: -2.7 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-docs Precedence: bulk Sender: pgsql-docs-owner@postgresql.org --001a1140faa80eb02405204a6507 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Monday, September 21, 2015, Amir Rohan 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 wildcar= d > 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 =E2=94=82 bar =E2=94=82 ?column? > =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=BC=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=BC=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80 > 1 =E2=94=82 2 =E2=94=82 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 checke= d > 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. --001a1140faa80eb02405204a6507 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Monday, September 21, 2015, Amir Rohan <amir.rohan@mail.com> wrote:
=C2=A0

=C2=A0 ##SELECT List

=C2=A0=C2=A0=C2=A0 <...>
=C2=A0=C2=A0=C2=A0 Instead of an expression, * can be written= in the output list as a shorthand for all the columns of the selected rows= .
=C2=A0=C2=A0=C2=A0 Also, you can write table_name.* = as a shorthand for the columns coming from just that table. In these cases = it is not
=C2=A0=C2=A0=C2=A0 possible to specify new names with AS; the= output column names will be the same as the table columns' names.
=C2=A0
But,=C2=A0the 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 colu= mns as you wish:
=C2=A0
WITH T0 as ( SELECT 1,2,3 )
SELECT T0.* from T0 as T0(foo,bar) ;
=C2=A0
=C2=A0foo =E2=94=82 bar =E2=94=82 ?column?
=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=BC=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=BC=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80
=C2=A0=C2=A0 1 =E2=94=82=C2=A0=C2=A0 2 =E2=94=82=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 3
(1 row)
=C2=A0
The following curious variant also works:
=C2=A0
WITH T0 as ( SELECT 1,2,3 )
SELECT justAnythingReally.* from T0 as justAnythingReally(foo,bar) ;
=C2=A0
The synoposis/grammer at the top doesn't hint at this either. I= 9;ve checked and this has been supported since at least 9.2 .
=C2=A0

N= either of those examples is:

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

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

In t= his case the FROM clause is what is being alised.=C2=A0 It is documented th= ough I'd need to look to identify the specific location. It=C2=A0would = not be documented in a section regarding the select-list.

David J.
--001a1140faa80eb02405204a6507-- From amir.rohan@mail.com Sun May 24 04:56:36 2026 Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZeC13-0007ZH-AP for pgsql-docs@arkaria.postgresql.org; Tue, 22 Sep 2015 01:05:05 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZeC11-0002aT-Is for pgsql-docs@arkaria.postgresql.org; Tue, 22 Sep 2015 01:05:03 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZeC10-0002aI-5P for pgsql-docs@postgresql.org; Tue, 22 Sep 2015 01:05:02 +0000 Received: from mout.gmx.com ([74.208.4.201]) by magus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.84) (envelope-from ) id 1ZeC0w-00065O-7R for pgsql-docs@postgresql.org; Tue, 22 Sep 2015 01:05:01 +0000 Received: from [5.102.207.29] by 3capp-mailcom-lxa13.server.lan (via HTTP); Tue, 22 Sep 2015 03:04:53 +0200 MIME-Version: 1.0 Message-ID: From: "Amir Rohan" To: "David G. Johnston" Cc: "pgsql-docs@postgresql.org" Subject: Re: Docs claim that "select myTable.*" wildcard won't let you assign column names Content-Type: text/plain; charset=UTF-8 Date: Tue, 22 Sep 2015 03:04:53 +0200 Importance: normal Sensitivity: Normal In-Reply-To: References: , X-UI-Message-Type: mail X-Priority: 3 X-Provags-ID: V03:K0:8c3gk2clyS+bgO/QDW4F98VzNRUVdZEtXdEtNgU4BkK mz9GOFqcZrRTqjSBmguwp/ZwJ1KgryeSPLQJ9WOTqhtZPr+2lj 94SbH0xGQgHR4fGmEUaMTqz1NIEfm/3FW1ectY1um4KXN/p8Fi XbQe0aoxAq+FORgeXK0YtWYI3AuSD9Jwuo9LKiD6WGsBLBv+X7 bSdlVr+M+kLzWOKsSwaVx+vinqpVc1dCcF4Ulf/9+nNPxUDiMD +rQSEuXxd2MN07wzE3dfUeC2FvHuSkaFV9sD1JNqFszBUvB8ms oRbg3oWS3oij3aFPR4TmmnNiQFz X-UI-Out-Filterresults: notjunk:1;V01:K0:D4Ic60lX+jA=:hVPoHvR18CmG55vidgrqoF PXHVfb2uUi4Ns0/06YesGc+S7jwVIZOwtv0ROHQrJ3jFSj5mcOnHBxdJ8Cmz84+ZnecQ/bdzK Ua3pxoSHk3+YIwy02BmDGE35lvRT3NC3qxYAFs8bAoKR7EnMKR/xQqkR5QrkTawXnEJ/7Ajol EJiLbT6fWPNPin6XBG2CS35WPRVg2WXbFACkpNVsA1AQ7p5ieheq3RDHwz3kSregH20TduL/6 iUv1w+JLobNBHUmulY4f2LeL+2rY43Epl41QwXt9wpFCI5sAc8DccTQ4IiLtVL/ucTlx+I7Xs sQP5yqPK7mB0Krf88sWhLqo4AaOjwiJxo7I6spprSv9UIjcx71zfeUmY+alxj1S5o2UBWJ7m7 08CV6+u06hksz5D/4qIyJyvwpLsullgsG6Yj+wFHgP7KKAA2KaPABOjqWv1IiJrx2t0fhxJ86 9eQInYF8sQ== X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-docs Precedence: bulk Sender: pgsql-docs-owner@postgresql.org On Monday, September 21, 2015, Amir Rohan 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. Amir -- Sent via pgsql-docs mailing list (pgsql-docs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-docs From mail@joeconway.com Sun May 24 04:56:36 2026 Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZeCRm-0008W2-57 for pgsql-docs@arkaria.postgresql.org; Tue, 22 Sep 2015 01:32:42 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZeCRl-0003vp-ND for pgsql-docs@arkaria.postgresql.org; Tue, 22 Sep 2015 01:32:41 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZeCRQ-0003YF-Rr for pgsql-docs@postgresql.org; Tue, 22 Sep 2015 01:32:21 +0000 Received: from wsip-72-214-29-243.sd.sd.cox.net ([72.214.29.243] helo=joeconway.com) by makus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1ZeCRO-0000rk-0K for pgsql-docs@postgresql.org; Tue, 22 Sep 2015 01:32:19 +0000 Received: from [192.168.4.41] (account jconway@joeconway.com [192.168.4.41] verified) by joeconway.com (CommuniGate Pro SMTP 6.1.4) with ESMTPSA id 15613474; Mon, 21 Sep 2015 18:32:16 -0700 Subject: Re: Docs claim that "select myTable.*" wildcard won't let you assign column names To: Amir Rohan , "David G. Johnston" References: Cc: "pgsql-docs@postgresql.org" From: Joe Conway X-Enigmail-Draft-Status: N1110 Message-ID: <5600AFA0.8090809@joeconway.com> Date: Mon, 21 Sep 2015 18:32:16 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="MFCQkofMaQp8XH2T695NcwAJDtrf4VX0d" X-Pg-Spam-Score: -0.9 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-docs Precedence: bulk Sender: pgsql-docs-owner@postgresql.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --MFCQkofMaQp8XH2T695NcwAJDtrf4VX0d Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/21/2015 06:04 PM, Amir Rohan wrote: > This belongs in the page describing SELECT, and though I've looked I ha= ven't found it. If I'm wrong ( > I did look again just now), please correct me. Feel free to submit a doc patch if you feel it needs to be improved, but it is mentioned here: http://www.postgresql.org/docs/9.4/interactive/sql-select.html#SQL-FROM 8<----------- alias A substitute name for the FROM item [...] If an alias is written, a column alias list can also be written to provide substitute names for one or more columns of the table. 8<----------- Joe --=20 Crunchy Data - http://crunchydata.com PostgreSQL Support for Secure Enterprises Consulting, Training, & Open Source Development --MFCQkofMaQp8XH2T695NcwAJDtrf4VX0d Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAEBAgAGBQJWAK+gAAoJEDfy90M199hl7c4QAJzx6IqyUGcVe+cneV4GRGAR /PS+7e3Um1xqYIl2xrCLlubm83nmSeHcNfYLWwAd7IEPWybeZT03bFntCtJNmft9 L4lwjEaJoKHBECtPTm528fO5mUR2LtzxySy6mvO/qx/noXyUYQ7rjxLF3JU+35S3 Ifp/gBBIthA9FITRrzfjdHCFoADKjrtipfBBweeSCa/Dki1qE9BEkF38xxLZ0sBo hzo2kcxFBItqgbnYqNSRGULy9Lb6OJCrd7PGoouYyvW0kwQBrCi5dQvS2iIssAh3 UNENZYZF79pL4ZyszcH4IMOARDZx2qqxemKdL9bFoAXxCL8reXMFl+g1++tVtRSZ qE5owFC5HtGtZ2EynfwMsGlf7b1sWv2wzaO5i/Yxl1g9oqnMMbeKE91e+BDgGc3e J4CFeH7br/50ifgZmdxlIk/neTxQ1083hJNU90btT6n2FH3oyOvgLF4jp2JX3BjY pTxIP4fb4Sn8UoerS5TKgdhdHFF6Yao6BODhiQBd7qsgwLn5IId7yZOqnph2curZ P0COiKz8Od5UoLVUcjzkw1DyPwNojXc2GgxfgAcmH5Rhe1ZVS6f1Xjo+2Xf71+7L PwL8mINXv85Z2/bvscwauvBUs+tL21VsvYMD0lyN2aha8aqCFr771reyeiEbhFT1 VY7ONlGLYpVTl6JDnDeA =1AIi -----END PGP SIGNATURE----- --MFCQkofMaQp8XH2T695NcwAJDtrf4VX0d-- From david.g.johnston@gmail.com Sun May 24 04:56:37 2026 Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZeCrj-00018B-0M for pgsql-docs@arkaria.postgresql.org; Tue, 22 Sep 2015 01:59:31 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZeCri-0004ox-3k for pgsql-docs@arkaria.postgresql.org; Tue, 22 Sep 2015 01:59:30 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZeCrL-0004RC-Ip for pgsql-docs@postgresql.org; Tue, 22 Sep 2015 01:59:07 +0000 Received: from mail-io0-x22f.google.com ([2607:f8b0:4001:c06::22f]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1ZeCrE-0001Li-Da for pgsql-docs@postgresql.org; Tue, 22 Sep 2015 01:59:06 +0000 Received: by ioii196 with SMTP id i196so2620317ioi.3 for ; Mon, 21 Sep 2015 18:58:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=xEzL9i2nS76sNvUmnCWKkpkExbXsySmfPBFhJWuWxO0=; b=JRvbm42pw2bu3OtH/EwhI7sxmj9Fvz5GyfnPUoRj9Cm8MnVVEbDg1OHhnZHJXpqC1O HUVMKLnKlLKGEcyrD9wgYGVpoAaP7jSHaIISS0Hnet1KI3FbXCpYPfDDUoIUuZFnfx7M 7SS8PDKTQm6WVhlFPmBXngmDPW45AxY1KyDLNnQaPMo2RdJ3924QO74O14N8b0c4227V Df2E9UoaZR7kuaPbSfTgvzRpKK2G+8tzIeHkLtSlCwXsdGdNHUFwM4RGXreZj9mytOuR /sYyQ0MLR/3vK89mKtJ3iLElN9clRGGoZ1yGPSHhnf9pWopJN7qY8DERv6uX/hbQDZZL yxaA== MIME-Version: 1.0 X-Received: by 10.107.6.73 with SMTP id 70mr28125556iog.158.1442887138925; Mon, 21 Sep 2015 18:58:58 -0700 (PDT) Received: by 10.36.143.141 with HTTP; Mon, 21 Sep 2015 18:58:58 -0700 (PDT) In-Reply-To: References: Date: Mon, 21 Sep 2015 21:58:58 -0400 Message-ID: Subject: Re: Docs claim that "select myTable.*" wildcard won't let you assign column names From: "David G. Johnston" To: Amir Rohan Cc: "pgsql-docs@postgresql.org" Content-Type: multipart/alternative; boundary=001a113f8cb85de29205204c5776 X-Pg-Spam-Score: -1.7 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-docs Precedence: bulk Sender: pgsql-docs-owner@postgresql.org --001a113f8cb85de29205204c5776 Content-Type: text/plain; charset=UTF-8 On Monday, September 21, 2015, Amir Rohan wrote: > On Monday, September 21, 2015, Amir Rohan > 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. --001a113f8cb85de29205204c5776 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Monday, September 21, 2015, Amir Rohan <amir.rohan@mail.com> wrote:
On Monday, September 21, 2015, Amir Rohan <amir.r= ohan@mail.com> wrote:


>> From h= ttp://www.postgresql.org/docs/9.4/static/sql-select.html[http://www.postgre= sql.org/docs/9.4/static/sql->> select.html] (and previous version= too):
>>
>>=C2=A0 =C2=A0##SELECT List
>>
>>=C2=A0 =C2=A0 =C2=A0<...>
>>=C2=A0 =C2=A0 =C2=A0Instead of an expression, * can be written in t= he output list as a shorthand for all the columns of the
>>=C2=A0 =C2=A0 =C2=A0selected rows.
>>=C2=A0 =C2=A0 =C2=A0Also, you can write table_name.* as a shorthand= for the columns coming from just that table. In these
>>=C2=A0 =C2=A0 =C2=A0cases it is not possible to specify new names w= ith AS; the output column names will be the same as the
>>=C2=A0 =C2=A0 =C2=A0table 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 nam= es with AS" is misleading because
it *is* possible and useful, but requires syntax which isn't clearly sh= own (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-li= st 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.=C2=A0 It is doc= umented though I'd need to look to
> identify the specific location.

This belongs in the page describing SELECT, and though I've looked I ha= ven't found it. If I'm wrong (
I did look again just now), please correct me.


To be honest, if you have a situation wher= e you think you need to alias "*" you should probably be expandin= g that "*" out into individual column names anyway, which you can= easily alias.

The docs don't make a big deal of al= ising other than noting individually where they can happen (cte, from claus= e, select-list) and few questions that are raised are probably better serve= d to be simply handled on these lists than cluttering the docs.
David J.=C2=A0
--001a113f8cb85de29205204c5776-- From amir.rohan@mail.com Sun May 24 04:56:37 2026 Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZeTRR-0001kK-Dh for pgsql-docs@arkaria.postgresql.org; Tue, 22 Sep 2015 19:41:29 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZeTRQ-00070f-V6 for pgsql-docs@arkaria.postgresql.org; Tue, 22 Sep 2015 19:41:29 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZeTR5-0006d2-QL for pgsql-docs@postgresql.org; Tue, 22 Sep 2015 19:41:07 +0000 Received: from mout.gmx.com ([74.208.4.200]) by makus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.84) (envelope-from ) id 1ZeTQz-0005HO-8p for pgsql-docs@postgresql.org; Tue, 22 Sep 2015 19:41:06 +0000 Received: from [5.102.207.29] by 3capp-mailcom-lxa05.server.lan (via HTTP); Tue, 22 Sep 2015 21:40:58 +0200 MIME-Version: 1.0 Message-ID: From: "Amir Rohan" To: "David G. Johnston" Cc: "pgsql-docs@postgresql.org" Subject: Re: Docs claim that "select myTable.*" wildcard won't let you assign column names Content-Type: text/plain; charset=UTF-8 Date: Tue, 22 Sep 2015 21:40:58 +0200 Importance: normal Sensitivity: Normal In-Reply-To: References: , X-UI-Message-Type: mail X-Priority: 3 X-Provags-ID: V03:K0:kPbIq3b+OAQ6AjyOcMXyYqU5IKrsbSiWNwUSJ+IoDpi u1v7Z2ieCi4Tzi1pqiGOD2efLQ7cNq4XtYMipGUBHlpKa7XkuJ K6JjibK8xolx5hFM2vZ1QIilYwkaj/GazDQom6yUJJr+ChWdU0 /2vkmnryiMh3tQh1kzG0NiRZ3FJvO0i9gM7HQVEUYZv8Br5+4S caxMAttHzxb1lonKiVVHNvDKu2WHNV+WcWIFW38aGLHtSNcfzK Xah4X3TxoeLX48BrD63DkDZeipOpCkmKY+dgO3bkaqQdLe7W5g XMbnUjET6aPqIdayYkwx8JftOgi X-UI-Out-Filterresults: notjunk:1;V01:K0:twxsvtLhvbQ=:XUhYxBs5tjt1h8+sMnm++C bw1jyC6Dn1uAOmFkS0yp9gkGiLlvw5siiFfu3TSWYZqODeLC+V8JPVEJYxg28Sjn8XEpdwrYD Lx4v/W2Kkw01LeknCjytTG+AAw0G8lUiNF9bNZaLMvc6TOmdI64ThETI0cm6UIzR9qIjTBsF9 T36Ki16VMpYZRMr19e+eTrDPYtqRRo9NLfBo6GdIaMJLJwayfv2dXaJlZ5ygbxAdj/X7Zw8K4 qQN4C81fUCEbYvSdGL+ZnUSmQwk8m7czu/wHROGPSheCqrJbKYtcK1jIEyVfYgCukSs/sdLuQ RqqDrcrLn6l+vGZeiZpOu2ZjNGHqUPqLJpKM6yY2oxlLaNdpzIWqQLcNKH38phM4AUA6qIi6h novXt0VEpf05J4AdqVDsrqmPsSq9qO2Tqjw51b6xGgfqVECJmzmfQbXKe/KXDJIdjhw2c+rRE Mdt7GNE6+g== X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-docs Precedence: bulk Sender: pgsql-docs-owner@postgresql.org On Monday, September 21, 2015, David G. Johnston wrote: >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. > That depends. If my table has 30 columns and I just need to rename the first couple, then I probably would find that advice unreasonable. >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. What constitutes "clutter", or what is "obvious", really depends on who is making the assertion. A pg veteran's views probably don't mirrort those of the person you'd typically find actually reading the docs, trying to figure out how to write the query they want. But yeah, the pg documentation isn't the best resource to pick up SQL from (nor is is their purpose), and no patch I'd submit would really change that. So, we're done. Amir -- Sent via pgsql-docs mailing list (pgsql-docs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-docs