4.2.4. Field Selection

4.2.4. Field Selection

4.2.4.区域选择

If an expression yields a value of a composite type (row type), then a specific field of the row can be extracted by writing

如果一个表达式表示了复合类型(行类型)的值,那么可以通过以下写法提取行的指定字段:

expression.fieldname

In general the row expression must be parenthesized, but the parentheses can be omitted when the expression to be selected from is just a table reference or positional parameter. For example:

一般情况下,行expression必须括起来,但是如果选择的表达式仅仅是一个表或者位置参数,则可以忽略括号。例如:

mytable.mycolumn

$1.somecolumn

(rowfunction(a,b)).col3

(Thus, a qualified column reference is actually just a special case of the field selection syntax.) An important special case is extracting a field from a table column that is of a composite type:

(也就是说,列选择只是区域选择的特例而已。) 一个重要的特殊情况是从复合类型的表列中提取字段:

(compositecol).somefield

(mytable.compositecol).somefield

The parentheses are required here to show that compositecol is a column name not a table name,or that mytable is a table name not a schema name in the second case.

这里的括号是必需的,是为了表示compositecol是一个列名而不是表名,或者mytable是一个表名而不是模式名。

You can ask for all fields of a composite value by writing .*:

可以通过使用.*来匹配复合类型的所有区域:

(compositecol).*

This notation behaves differently depending on context; see Section 8.16.5 for details.

根据上下文的不同,此表示法的行为也有所不同。 有关详细信息,请参见第8.16.5节

发布了341 篇原创文章 · 获赞 53 · 访问量 88万+

猜你喜欢

转载自blog.csdn.net/ghostliming/article/details/104259920