7.3.2. Column Labels

7.3.2. Column Labels
7.3.2.列标签
The entries in the select list can be assigned names for subsequent processing, such as for use in an  ORDER BY clause or for display by the client application. For example:
可以为选择列表中的条目分配名称,以进行后续处理,例如在ORDER BY子句中使用或由客户端应用程序显示。 例如:
 
SELECT a AS value, b + c AS sum FROM ...
 
If no output column name is specified using AS , the system assigns a default column name. For simple  column references, this is the name of the referenced column. For function calls, this is the name of  the function. For complex expressions, the system will generate a generic name.
如果未使用AS指定输出列名称,则系统会分配一个默认列名称。对于简单的列引用,就是被引用列的名称。对于函数调用,就是函数的名称。对于复杂的表达式,系统将生成一个通用名称。
 
The AS keyword is optional, but only if the new column name does not match any PostgreSQL keyword  (see Appendix C). To avoid an accidental match to a keyword, you can double-quote the column  name. For example, VALUE is a keyword, so this does not work:
但是仅当新列名与任何PostgreSQL关键字都不匹配时(请参见附录C), AS关键字才是可选的 。为避免与关键字意外撞车,您可以将列名加双引号。 例如,VALUE是一个关键字,因此以下是一个错误的示例:
 
SELECT a value, b + c AS sum FROM ...
 
but this does:
但下面的示例则是可行的:
 
SELECT a "value", b + c AS sum FROM ...
 
For protection against possible future keyword additions, it is recommended that you always either  write AS or double-quote the output column name.
为了防止与将来可能增加的关键字撞车,建议始终写AS或用双引号将 输出列名称 引起来。
 
Note
The naming of output columns here is different from that done in the FROM clause (see  Section 7.2.1.2). It is possible to rename the same column twice, but the name assigned  in the select list is the one that will be passed on.
此处为输出列命名与FROM子句的操作不同(参见 7.2.1.2节)。 可以将同一列重命名两次,但是在选择列表中分配的名称是将要传递的名称。
 
 
 
发布了341 篇原创文章 · 获赞 54 · 访问量 88万+

猜你喜欢

转载自blog.csdn.net/ghostliming/article/details/104549911
今日推荐