其他分享
首页 > 其他分享> > 8.16.2. Constructing Composite Values

8.16.2. Constructing Composite Values

作者:互联网

8.16.2. Constructing Composite Values 8.16.2.构建复合值 To write a composite value as a literal constant, enclose the field values within parentheses and separate  them by commas. You can put double quotes around any field value, and must do so if it contains  commas or parentheses. (More details appear below.) Thus, the general format of a composite constant  is the following: 要将复合值写为文字常量,请将字段值括在括号中,并用逗号分隔。 您可以在任何字段值两边加上双引号,并且如果值包含逗号或括号,则必须使用双引号。 (更多详细信息请继续看。)因此,复合常量的一般格式如下:   '( val1 , val2 , ... )'   An example is: 示例:   '("fuzzy dice",42,1.99)'   which would be a valid value of the inventory_item type defined above. To make a field be  NULL, write no characters at all in its position in the list. For example, this constant specifies a NULL  third field: 这是上面定义的stock_item类型的有效值。要使字段为NULL,请在列表中的相应位置完全不写任何字符。 例如,此常量将 第三字段 指定为NULL:   '("fuzzy dice",42,)'   If you want an empty string rather than NULL, write double quotes: 如果需要一个空的字符串而不是NULL,则可以只写两个双引号:   '("",42,)'   Here the first field is a non-NULL empty string, the third is NULL. 上例中的第一个区域为非NULL的空字符串,第三个字段为NULL。   (These constants are actually only a special case of the generic type constants discussed in Section  4.1.2.7. The constant is initially treated as a string and passed to the composite-type input conversion  routine. An explicit type specification might be necessary to tell which type to convert the  constant to.)  (这些常量实际上只是 第4.1.2.7节 中讨论的泛型类型常量的一种特殊情况。该常量最初被视为字符串,并传递给复合类型输入转换例程。可能需要显式类型说明来确定将常量类型转换为哪种。)   The ROW expression syntax can also be used to construct composite values. In most cases this is  considerably simpler to use than the string-literal syntax since you don't have to worry about multiple  layers of quoting. We already used this method above: ROW表达式语法也可以用于构造复合值。 在大多数情况下,这比字符串文字语法要简单得多,因为您不必担心多层引号。上面我们已经使用了这种方法:   ROW('fuzzy dice', 42, 1.99) ROW('', 42, NULL)   The ROW keyword is actually optional as long as you have more than one field in the expression,  so these can be simplified to: 只要至少有一个值,则ROW关键词可以忽略,所以上例可以简写为:   ('fuzzy dice', 42, 1.99) ('', 42, NULL)   The ROW expression syntax is discussed in more detail in Section 4.2.13. 关于ROW的更多信息,参见 4.2.13

标签:NULL,常量,Composite,42,field,Values,8.16,type,ROW
来源: https://blog.csdn.net/ghostliming/article/details/112299296