> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-fix-nav-issues.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> creates a temporary storage which fills columns with values.

# values

The `Values` table function allows you to create temporary storage which fills
columns with values. It is useful for quick testing or generating sample data.

<Note>
  Values is a case-insensitive function. I.e. `VALUES` or `values` are both valid.
</Note>

<h2 id="syntax">
  Syntax
</h2>

The basic syntax of the `VALUES` table function is:

```sql theme={null}
VALUES([structure,] values...)
```

It is commonly used as:

```sql theme={null}
VALUES(
    ['column1_name Type1, column2_name Type2, ...'],
    (value1_row1, value2_row1, ...),
    (value1_row2, value2_row2, ...),
    ...
)
```

<h2 id="arguments">
  Arguments
</h2>

* `column1_name Type1, ...` (optional). [String](/reference/data-types/string)
  specifying the column names and types. If this argument is omitted columns will
  be named as `c1`, `c2`, etc.
* `(value1_row1, value2_row1)`. [Tuples](/reference/data-types/tuple)
  containing values of any type.

<Note>
  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](#examples) section for
  details.
</Note>

<h2 id="returned-value">
  Returned value
</h2>

* Returns a temporary table containing the provided values.

<h2 id="examples">
  Examples
</h2>

```sql title="Query" theme={null}
SELECT *
FROM VALUES(
    'person String, place String',
    ('Noah', 'Paris'),
    ('Emma', 'Tokyo'),
    ('Liam', 'Sydney'),
    ('Olivia', 'Berlin'),
    ('Ilya', 'London'),
    ('Sophia', 'London'),
    ('Jackson', 'Madrid'),
    ('Alexey', 'Amsterdam'),
    ('Mason', 'Venice'),
    ('Isabella', 'Prague')
)
```

```response title="Response" theme={null}
    ┌─person───┬─place─────┐
 1. │ Noah     │ Paris     │
 2. │ Emma     │ Tokyo     │
 3. │ Liam     │ Sydney    │
 4. │ Olivia   │ Berlin    │
 5. │ Ilya     │ London    │
 6. │ Sophia   │ London    │
 7. │ Jackson  │ Madrid    │
 8. │ Alexey   │ Amsterdam │
 9. │ Mason    │ Venice    │
10. │ Isabella │ Prague    │
    └──────────┴───────────┘
```

`VALUES` can also be used with single values rather than tuples. For example:

```sql title="Query" theme={null}
SELECT *
FROM VALUES(
    'person String',
    'Noah',
    'Emma',
    'Liam',
    'Olivia',
    'Ilya',
    'Sophia',
    'Jackson',
    'Alexey',
    'Mason',
    'Isabella'
)
```

```response title="Response" theme={null}
    ┌─person───┐
 1. │ Noah     │
 2. │ Emma     │
 3. │ Liam     │
 4. │ Olivia   │
 5. │ Ilya     │
 6. │ Sophia   │
 7. │ Jackson  │
 8. │ Alexey   │
 9. │ Mason    │
10. │ Isabella │
    └──────────┘
```

Or without providing a row specification (`'column1_name Type1, column2_name Type2, ...'`
in the [syntax](#syntax)), in which case the columns are automatically named.

For example:

```sql title="Query" theme={null}
-- tuples as values
SELECT *
FROM VALUES(
    ('Noah', 'Paris'),
    ('Emma', 'Tokyo'),
    ('Liam', 'Sydney'),
    ('Olivia', 'Berlin'),
    ('Ilya', 'London'),
    ('Sophia', 'London'),
    ('Jackson', 'Madrid'),
    ('Alexey', 'Amsterdam'),
    ('Mason', 'Venice'),
    ('Isabella', 'Prague')
)
```

```response title="Response" theme={null}
    ┌─c1───────┬─c2────────┐
 1. │ Noah     │ Paris     │
 2. │ Emma     │ Tokyo     │
 3. │ Liam     │ Sydney    │
 4. │ Olivia   │ Berlin    │
 5. │ Ilya     │ London    │
 6. │ Sophia   │ London    │
 7. │ Jackson  │ Madrid    │
 8. │ Alexey   │ Amsterdam │
 9. │ Mason    │ Venice    │
10. │ Isabella │ Prague    │
    └──────────┴───────────┘
```

```sql title="Query" theme={null}
-- single values
SELECT *
FROM VALUES(
    'Noah',
    'Emma',
    'Liam',
    'Olivia',
    'Ilya',
    'Sophia',
    'Jackson',
    'Alexey',
    'Mason',
    'Isabella'
)
```

```response title="Response" theme={null}
    ┌─c1───────┐
 1. │ Noah     │
 2. │ Emma     │
 3. │ Liam     │
 4. │ Olivia   │
 5. │ Ilya     │
 6. │ Sophia   │
 7. │ Jackson  │
 8. │ Alexey   │
 9. │ Mason    │
10. │ Isabella │
    └──────────┘
```

<h2 id="sql-standard-values-clause">
  SQL Standard VALUES Clause
</h2>

From version 26.3, ClickHouse also supports the SQL standard `VALUES` 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.

```sql title="Query" theme={null}
SELECT * FROM (VALUES (1, 'a'), (2, 'b'), (3, 'c')) AS t(id, val);
```

```response title="Response" theme={null}
┌─id─┬─val─┐
│  1 │ a   │
│  2 │ b   │
│  3 │ c   │
└────┴─────┘
```

It can be used in CTEs:

```sql title="Query" theme={null}
WITH cte AS (SELECT * FROM (VALUES (1, 'one'), (2, 'two')) AS t(id, name))
SELECT * FROM cte;
```

And in JOINs:

```sql title="Query" theme={null}
SELECT t1.id, t1.val, t2.val2
FROM (VALUES (1, 'a'), (2, 'b')) AS t1(id, val)
JOIN (VALUES (1, 'x'), (2, 'y')) AS t2(id, val2) ON t1.id = t2.id;
```

<Note>
  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.
</Note>

<h2 id="see-also">
  See also
</h2>

* [Values format](/reference/formats/Values)
