public inbox for [email protected]  
help / color / mirror / Atom feed
From: Amir Rohan <[email protected]>
To: [email protected]
Subject: Docs claim that "select myTable.*" wildcard won't let you assign column names
Date: Tue, 22 Sep 2015 00:37:33 +0200
Message-ID: <trinity-f7a55438-da76-471a-8b06-b5446f01918b-1442875052542@3capp-mailcom-lxa10> (raw)
List-Unsubscribe: <mailto:[email protected]?body=unsub%20pgsql-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>




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]
  Subject: Re: Docs claim that "select myTable.*" wildcard won't let you assign column names
  In-Reply-To: <trinity-f7a55438-da76-471a-8b06-b5446f01918b-1442875052542@3capp-mailcom-lxa10>

* 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