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