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

From: "Amir Rohan" <amir(dot)rohan(at)mail(dot)com>
To: pgsql-docs(at)postgresql(dot)org
Subject: Docs claim that "select myTable.*" wildcard won't let you assign column names
Date: 2015-09-21 22:37:33
Message-ID: trinity-f7a55438-da76-471a-8b06-b5446f01918b-1442875052542@3capp-mailcom-lxa10
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

<html><head></head><body><div style="font-family: Verdana;font-size: 12.0px;"><div>&nbsp;</div>

<div>From http://www.postgresql.org/docs/9.4/static/sql-select.html (and previous version too):</div>

<div>
<h3><tt class="COMMAND">&nbsp; ##SELECT</tt> List</h3>

<div>&nbsp;&nbsp;&nbsp; &lt;...&gt;</div>
</div>

<div>&nbsp;&nbsp;&nbsp; Instead of an expression, <tt class="LITERAL">*</tt> can be written in the output list as a shorthand for all the columns of the selected rows.</div>

<div>&nbsp;&nbsp;&nbsp; Also, you can write <tt class="LITERAL"><tt class="REPLACEABLE c2">table_name</tt>.*</tt> as a shorthand for the columns coming from just that table. In these cases it is not</div>

<div>&nbsp;&nbsp;&nbsp; possible to specify new names with <tt class="LITERAL">AS</tt>; the output column names will be the same as the table columns&#39; names.</div>

<div>&nbsp;</div>

<div>But,&nbsp;the docs elsewhere feature a query example show the use of a wildcard for columns</div>

<div>as well as allowing you to assign names to as many of the leading columns as you wish:</div>

<div>&nbsp;
<div>
<div>WITH T0 as ( SELECT 1,2,3 )<br/>
SELECT T0.* from T0 as T0(foo,bar) ;</div>

<div>&nbsp;</div>

<div>
<div>&nbsp;foo &#9474; bar &#9474; ?column?<br/>
&#9472;&#9472;&#9472;&#9472;&#9472;&#9532;&#9472;&#9472;&#9472;&#9472;&#9472;&#9532;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;<br/>
&nbsp;&nbsp; 1 &#9474;&nbsp;&nbsp; 2 &#9474;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3<br/>
(1 row)</div>

<div>&nbsp;</div>

<div>The following curious variant also works:</div>

<div>&nbsp;</div>

<div>WITH T0 as ( SELECT 1,2,3 )<br/>
SELECT justAnythingReally.* from T0 as justAnythingReally(foo,bar) ;</div>
</div>
&nbsp;

<div>The synoposis/grammer at the top doesn&#39;t hint at this either. I&#39;ve checked and this has been supported since at least 9.2 .</div>

<div>&nbsp;</div>

<div>Regards,</div>

<div>Amir</div>

<div>&nbsp;</div>
</div>
</div></div></body></html>

Attachment Content-Type Size
unknown_filename text/html 2.0 KB

Responses

Browse pgsql-docs by date

  From Date Subject
Next Message David G. Johnston 2015-09-21 23:39:38 Re: Docs claim that "select myTable.*" wildcard won't let you assign column names
Previous Message Petr Jelinek 2015-09-16 03:12:34 Re: [DOCS] max_worker_processes on the standby