ClickHouse Client

Note

Instead of the `--host`, `--port`, `--user` and `--password` options, the client also supports [connection strings](#connection_string).

### Query options[​](#command-line-options-query "Direct link to Query options")

|  |  |  |  |  |  |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| Option Description|  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | | `--param_<name>=<value>` Substitution value for a parameter of a [query with parameters](#cli-queries-with-parameters).| `-q [ --query ] <query>` The query to run in batch mode. Can be specified multiple times (`--query "SELECT 1" --query "SELECT 2"`) or once with multiple semicolon-separated queries (`--query "SELECT 1; SELECT 2;"`). In the latter case, `INSERT` queries with formats other than `VALUES` must be separated by empty lines.   A single query can also be specified without a parameter: `clickhouse-client "SELECT 1"`   Cannot be used together with `--queries-file`.| `--queries-file <path-to-file>` Path to a file containing queries. `--queries-file` can be specified multiple times, e.g. `--queries-file queries1.sql --queries-file queries2.sql`.   Cannot be used together with `--query`.| `-m [ --multiline ]` If specified, allow multiline queries (do not send the query on Enter). Queries will be sent only when they are ended with a semicolon. | | | | | | | | | |

### Query settings[​](#command-line-options-query-settings "Direct link to Query settings")

Query settings can be specified as command-line options in the client, for example:

```
$ clickhouse-client --max_threads 1
```

See [Settings](/docs/operations/settings/settings) for a list of settings.

### Formatting options[​](#command-line-options-formatting "Direct link to Formatting options")

|  |  |  |  |  |  |  |  |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| Option Description Default|  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `-f [ --format ] <format>` Use the specified format to output the result.   See [Formats for Input and Output Data](/docs/interfaces/formats) for a list of supported formats. `TabSeparated`| `--pager <command>` Pipe all output into this command. Typically `less` (e.g., `less -S` to display wide result sets) or similar. -|  |  |  | | --- | --- | --- | | `-E [ --vertical ]` Use the [Vertical format](/docs/interfaces/formats/Vertical) to output the result. This is the same as `–-format Vertical`. In this format, each value is printed on a separate line, which is helpful when displaying wide tables. - | | | | | | | | | | | |

### Execution details[​](#command-line-options-execution-details "Direct link to Execution details")

|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| Option Description Default|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `--enable-progress-table-toggle` Enable toggling of the progress table by pressing the control key (Space). Only applicable in interactive mode with progress table printing enabled. `enabled`| `--hardware-utilization` Print hardware utilization information in progress bar. -|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `--memory-usage` If specified, print memory usage to `stderr` in non-interactive mode.   Possible values:  • `none` - do not print memory usage  • `default` - print number of bytes  • `readable` - print memory usage in human-readable format -|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `--print-profile-events` Print `ProfileEvents` packets. -|  |  |  |  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `--progress` Print progress of query execution.   Possible values:  • `tty|on|1|true|yes` - outputs to the terminal in interactive mode  • `err` - outputs to `stderr` in non-interactive mode  • `off|0|false|no` - disables progress printing `tty` in interactive mode, `off` in non-interactive (batch) mode| `--progress-table` Print a progress table with changing metrics during query execution.   Possible values:  • `tty|on|1|true|yes` - outputs to the terminal in interactive mode  • `err` - outputs to `stderr` non-interactive mode  • `off|0|false|no` - disables the progress table `tty` in interactive mode, `off` in non-interactive (batch) mode| `--stacktrace` Print stack traces of exceptions. -|  |  |  | | --- | --- | --- | | `-t [ --time ]` Print query execution time to `stderr` in non-interactive mode (for benchmarks). - | | | | | | | | | | | | | | | | | | | | | | | | | | |

- [Install](#install)- [Run](#run)
    - [Connecting to ClickHouse Cloud](#connecting-cloud)- [Storing connections in a configuration file](#connection-credentials)- [Interactive mode](#interactive-mode)
      - [Using interactive mode](#using-interactive-mode)- [Query processing information](#processing-info)- [Aliases](#cli_aliases)- [Keyboard shortcuts](#keyboard_shortcuts)- [Batch mode](#batch-mode)
        - [Using batch mode](#using-batch-mode)- [Inserting a CSV file into a remote ClickHouse service](#cloud-example)- [Examples of inserting data from the command line](#more-examples)- [Queries with parameters](#cli-queries-with-parameters)
          - [Query syntax](#cli-queries-with-parameters-syntax)- [Examples](#cli-queries-with-parameters-examples)- [AI-powered SQL generation](#ai-sql-generation)
            - [Usage](#ai-sql-generation-usage)- [Example](#ai-sql-generation-example)- [Configuration](#ai-sql-generation-configuration)- [Parameters](#ai-sql-generation-parameters)- [How it works](#ai-sql-generation-how-it-works)- [Limitations](#ai-sql-generation-limitations)- [Security](#ai-sql-generation-security)- [Connection string](#connection_string)
              - [Usage](#connection-string-usage)- [Notes](#connection-string-notes)- [Examples](#connection_string_examples)- [Query ID format](#query-id-format)- [Configuration files](#configuration_files)- [Environment variable options](#environment-variable-options)- [Command-line options](#command-line-options)
                      - [General options](#command-line-options-general)- [Connection options](#command-line-options-connection)- [Query options](#command-line-options-query)- [Query settings](#command-line-options-query-settings)- [Formatting options](#command-line-options-formatting)- [Execution details](#command-line-options-execution-details)

Was this page helpful?