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> </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>
Attachment | Content-Type | Size |
---|---|---|
unknown_filename | text/html | 2.0 KB |
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 |