Values table function allows you to create temporary storage which fills
columns with values. It is useful for quick testing or generating sample data.
Values is a case-insensitive function. I.e.
VALUES or values are both valid.Syntax
The basic syntax of theVALUES table function is:
Arguments
column1_name Type1, ...(optional). String specifying the column names and types. If this argument is omitted columns will be named asc1,c2, etc.(value1_row1, value2_row1). Tuples containing values of any type.
Comma separated tuples can be replaced by single values as well. In this case
each value is taken to be a new row. See the examples section for
details.
Returned value
- Returns a temporary table containing the provided values.
Examples
Query
Response
VALUES can also be used with single values rather than tuples. For example:
Query
Response
'column1_name Type1, column2_name Type2, ...'
in the syntax), in which case the columns are automatically named.
For example:
Query
Response
Query
Response
SQL Standard VALUES Clause
From version 26.3, ClickHouse also supports the SQL standardVALUES clause as a table expression
in FROM, as used in PostgreSQL, MySQL, DuckDB, and SQL Server. This syntax is
rewritten internally to use the values table function described above.
Query
Response
Query
Query
Column aliases after
AS t(col1, col2, ...) follow the standard SQL syntax for
naming columns of derived tables. If omitted, columns are named c1, c2, etc.