Docs claim that "select myTable.*" wildcard won't let you assign column names
От | Amir Rohan |
---|---|
Тема | Docs claim that "select myTable.*" wildcard won't let you assign column names |
Дата | |
Msg-id | trinity-f7a55438-da76-471a-8b06-b5446f01918b-1442875052542@3capp-mailcom-lxa10 обсуждение исходный текст |
Ответы |
Re: Docs claim that "select myTable.*" wildcard won't let you
assign column names
|
Список | pgsql-docs |
<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 shorthandfor the columns coming from just that table. In these cases it is not</div><div> possible to specify new nameswith <tt class="LITERAL">AS</tt>; the output column names will be the same as the table columns' names.</div><div> </div><div>But, thedocs elsewhere feature a query example show the use of a wildcard for columns</div><div>aswell as allowing you to assign names to as many of the leading columns as you wish:</div><div> <div><div>WITHT0 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 curiousvariant also works:</div><div> </div><div>WITH T0 as ( SELECT 1,2,3 )<br /> SELECT justAnythingReally.* from T0 asjustAnythingReally(foo,bar) ;</div></div> <div>The synoposis/grammer at the top doesn't hint at this either. I've checkedand this has been supported since at least 9.2 .</div><div> </div><div>Regards,</div><div>Amir</div><div> </div></div></div></div>
В списке pgsql-docs по дате отправления: