> ## 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.

# ClickHouse dictionary source

> Configure a ClickHouse table as a dictionary source.

Example of settings:

<Tabs>
  <Tab title="DDL">
    ```sql theme={null}
    SOURCE(CLICKHOUSE(
        host 'example01-01-1'
        port 9000
        user 'default'
        password ''
        db 'default'
        table 'ids'
        where 'id=10'
        secure 1
        query 'SELECT id, value_1, value_2 FROM default.ids'
    ));
    ```
  </Tab>

  <Tab title="Configuration file">
    ```xml theme={null}
    <source>
        <clickhouse>
            <host>example01-01-1</host>
            <port>9000</port>
            <user>default</user>
            <password></password>
            <db>default</db>
            <table>ids</table>
            <where>id=10</where>
            <secure>1</secure>
            <query>SELECT id, value_1, value_2 FROM default.ids</query>
        </clickhouse>
    </source>
    ```
  </Tab>
</Tabs>

<br />

Setting fields:

| Setting            | Description                                                                                                                                                                                                                                                        |
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `host`             | The ClickHouse host. If it is a local host, the query is processed without any network activity. To improve fault tolerance, you can create a [Distributed](/reference/engines/table-engines/special/distributed) table and enter it in subsequent configurations. |
| `port`             | The port on the ClickHouse server.                                                                                                                                                                                                                                 |
| `user`             | Name of the ClickHouse user.                                                                                                                                                                                                                                       |
| `password`         | Password of the ClickHouse user.                                                                                                                                                                                                                                   |
| `db`               | Name of the database.                                                                                                                                                                                                                                              |
| `table`            | Name of the table.                                                                                                                                                                                                                                                 |
| `where`            | The selection criteria. Optional.                                                                                                                                                                                                                                  |
| `invalidate_query` | Query for checking the dictionary status. Optional. Read more in the section [Refreshing dictionary data using LIFETIME](/reference/statements/create/dictionary/lifetime).                                                                                        |
| `secure`           | Use SSL for connection.                                                                                                                                                                                                                                            |
| `query`            | The custom query. Optional.                                                                                                                                                                                                                                        |

<Note>
  The `table` or `where` fields cannot be used together with the `query` field. And either one of the `table` or `query` fields must be declared.
</Note>
