4 VALUES provides a way to generate a “constant table” that can be used
5 in a query without having to actually create and populate a table
7 VALUES ( expression [, ...] ) [, ...]
9 Each parenthesized list of expressions generates a row in the table.
10 The lists must all have the same number of elements (i.e., the number
11 of columns in the table), and corresponding entries in each list must
12 have compatible data types. The actual data type assigned to each
13 column of the result is determined using the same rules as for UNION
17 VALUES (1, 'one'), (2, 'two'), (3, 'three');
19 will return a table of two columns and three rows. It's effectively
21 SELECT 1 AS column1, 'one' AS column2
27 By default, PostgreSQL assigns the names column1, column2, etc. to the
28 columns of a VALUES table. The column names are not specified by the
29 SQL standard and different database systems do it differently, so it's
30 usually better to override the default names with a table alias list,
32 => SELECT * FROM (VALUES (1, 'one'), (2, 'two'), (3, 'three')) AS t (num,letter)
41 Syntactically, VALUES followed by expression lists is treated as
43 SELECT select_list FROM table_expression
45 and can appear anywhere a SELECT can. For example, you can use it as
46 part of a UNION, or attach a sort_specification (ORDER BY, LIMIT,
47 and/or OFFSET) to it. VALUES is most commonly used as the data source
48 in an INSERT command, and next most commonly as a subquery.
50 For more information see VALUES.