# ClickHouse

Bobby Tables connects to ClickHouse through its HTTP interface and opens each connection in a SQL workspace that streams results and cancels queries by ID.

## Where to find it

| Action | How |
| --- | --- |
| Choose ClickHouse | `New connection`, `⌘N` (`Ctrl+N`), then `ClickHouse` under `Choose a provider` |
| Fill the form from a URL | `Use connection URL` with `clickhouse://` for HTTP or `clickhouses://` for HTTPS, then `Fill fields` |
| Defaults | Port `8123`, user `default`, database `default` |
`clickhouse+http://` and `clickhouse+https://` URLs are accepted too.

## Connecting

The form asks for `Host`, `Port`, `User`, `Database (optional)` and `Password`, and notes `Uses ClickHouse HTTP with query IDs and pooled connections`. New connections start with `SSL mode` set to `Disable`; `Require` encrypts without verification, `Verify Ca` checks the chain and `Verify Full` also checks the host name. Certificate files need an encrypted mode, and [SSH and TLS](https://bobbytables.app/docs/ssh-and-tls) covers tunnels. `Open in read-only mode` makes the app refuse writes and DDL with `ClickHouse connection is read-only`.

## What works

- Browse databases, tables, views, materialized views, engines, sizes and row estimates in the [table grid](https://bobbytables.app/docs/table-data).
- Grid updates and deletes are disabled because ClickHouse keys do not identify a row, as described in [Editing](https://bobbytables.app/docs/editing).
- Create, rename, truncate and drop tables, and add, drop, rename or modify columns, in the [Structure](https://bobbytables.app/docs/structure) tab.
- [Snapshots](https://bobbytables.app/docs/snapshots) are not available, so `Create snapshot...` does not appear.
- The [schema diagram](https://bobbytables.app/docs/schema-diagram) is unavailable, and its button says `This connection's driver does not report table relationships`.
- Format result columns with [result directives](https://bobbytables.app/docs/result-directives).
- Stop a running statement with `Cancel`, `⌘.` (`Ctrl+.`), which sends `KILL QUERY` for its query ID.
- Run `Explain`, `⌘⇧E` (`Ctrl+Shift+E`), or `Explain Analyze` for the pipeline, in the [SQL editor](https://bobbytables.app/docs/sql-editor).

## Engine notes

ClickHouse has no rollback guarantee, so scripts, DDL and imports run one statement at a time, and completed statements stay applied after a failure or a cancel. Committing a structure change opens `SQL preview` with that warning first. Run `ALTER TABLE ... UPDATE` or `ALTER TABLE ... DELETE` in the editor, and the app reports it only after the server finishes the mutation. Mutations need a `MergeTree` family table, and the server error is shown when an engine refuses one.

## Good to know

- Large integers and decimals arrive as exact text, and arrays, maps and tuples show as text.
- Primary and sorting keys order data, so they are never used to identify a row.

## Related

- [SQL editor](https://bobbytables.app/docs/sql-editor.md)
- [Structure](https://bobbytables.app/docs/structure.md)
- [SSH and TLS](https://bobbytables.app/docs/ssh-and-tls.md)
- [Engines, file sources and platforms](https://bobbytables.app/docs/engines.md)
