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

> Documentation for the Values format

# Values

| Input | Output | Alias |
| ----- | ------ | ----- |
| ✔     | ✔      |       |

<h2 id="description">
  Description
</h2>

The `Values` format prints every row in brackets.

* Rows are separated by commas without a comma after the last row.
* The values inside the brackets are also comma-separated.
* Numbers are output in a decimal format without quotes.
* Arrays are output in `[]`.
* Strings, dates, and dates with times are output in quotes.
* Escaping rules and parsing are similar to the [TabSeparated](/reference/formats/TabSeparated/TabSeparated) format.

During formatting, extra spaces aren't inserted, but during parsing, they are allowed and skipped (except for spaces inside array values, which are not allowed).
[`NULL`](/reference/syntax) is represented as `NULL`.

The minimum set of characters that you need to escape when passing data in the `Values` format:

* single quotes
* backslashes

This is the format that is used in `INSERT INTO t VALUES ...`, but you can also use it for formatting query results.

<h2 id="example-usage">
  Example usage
</h2>

<h3 id="inserting-data">
  Inserting data
</h3>

The `Values` format is what `INSERT` uses, so any `INSERT ... VALUES` statement
is already using it. The `FORMAT Values` clause can be stated explicitly, and the
rows can be supplied from a stream or a file. Each row is a bracketed,
comma-separated tuple, with the tuples themselves separated by commas:

```sql title="Query" theme={null}
CREATE TABLE t (id UInt32, name String, values Array(UInt32)) ENGINE = Memory;

INSERT INTO t FORMAT Values (1, 'a', [10, 20]), (2, 'b', [30]);

SELECT * FROM t ORDER BY id;
```

```response title="Response" theme={null}
┌─id─┬─name─┬─values──┐
│  1 │ a    │ [10,20] │
│  2 │ b    │ [30]    │
└────┴──────┴─────────┘
```

<h3 id="using-expressions">
  Using expressions on input
</h3>

Unlike most input formats, `Values` can evaluate SQL expressions in each field
rather than only accepting literals. This is controlled by
[`input_format_values_interpret_expressions`](#format-settings) (enabled by
default): when a field cannot be read by the fast streaming parser, ClickHouse
falls back to the SQL parser and interprets the field as an expression.

```sql title="Query" theme={null}
CREATE TABLE prices (item String, total UInt32) ENGINE = Memory;

INSERT INTO prices FORMAT Values ('apple', 3 * 4), ('pear', length('hello') + 10);

SELECT * FROM prices ORDER BY total;
```

```response title="Response" theme={null}
┌─item──┬─total─┐
│ apple │    12 │
│ pear  │    15 │
└───────┴───────┘
```

<h3 id="selecting-data">
  Selecting data
</h3>

The `Values` format can also be used to format query results. Numbers are
written without quotes, arrays in `[]`, and strings and dates in single quotes;
single quotes and backslashes inside strings are escaped with a backslash, and
[`NULL`](/reference/syntax) is written as `NULL`:

```sql title="Query" theme={null}
SELECT 1 AS a, 'O''Reilly' AS b, NULL::Nullable(String) AS c FORMAT Values;
```

```response title="Response" theme={null}
(1,'O\'Reilly',NULL)
```

<h2 id="format-settings">
  Format settings
</h2>

| Setting                                                                                                                                  | Description                                                                                                                                                                                   | Default |
| ---------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
| [`input_format_values_interpret_expressions`](/reference/settings/formats#input_format_values_interpret_expressions)                     | if the field could not be parsed by streaming parser, run SQL parser and try to interpret it as SQL expression.                                                                               | `true`  |
| [`input_format_values_deduce_templates_of_expressions`](/reference/settings/formats#input_format_values_deduce_templates_of_expressions) | if the field could not be parsed by streaming parser, run SQL parser, deduce template of the SQL expression, try to parse all rows using template and then interpret expression for all rows. | `true`  |
| [`input_format_values_accurate_types_of_literals`](/reference/settings/formats#input_format_values_accurate_types_of_literals)           | when parsing and interpreting expressions using template, check actual type of literal to avoid possible overflow and precision issues.                                                       | `true`  |
