public inbox for [email protected]
help / color / mirror / Atom feedFrom: 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> </div>
<div>From http://www.postgresql.org/docs/9.4/static/sql-select.html (and previous version too):</div>
<div>
<h3><tt class="COMMAND"> ##SELECT</tt> List</h3>
<div> <...></div>
</div>
<div> 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> 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> possible to specify new names with <tt class="LITERAL">AS</tt>; the output column names will be the same as the table columns' names.</div>
<div> </div>
<div>But, 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>
<div>
<div>WITH T0 as ( SELECT 1,2,3 )<br/>
SELECT T0.* from T0 as T0(foo,bar) ;</div>
<div> </div>
<div>
<div> foo │ bar │ ?column?<br/>
─────┼─────┼──────────<br/>
1 │ 2 │ 3<br/>
(1 row)</div>
<div> </div>
<div>The following curious variant also works:</div>
<div> </div>
<div>WITH T0 as ( SELECT 1,2,3 )<br/>
SELECT justAnythingReally.* from T0 as justAnythingReally(foo,bar) ;</div>
</div>
<div>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 .</div>
<div> </div>
<div>Regards,</div>
<div>Amir</div>
<div> </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