| name | clickhouse-hello-world |
| description | Create your first ClickHouse table, insert data, and run analytical queries.
Use when starting a new ClickHouse project, learning MergeTree basics,
or testing your ClickHouse connection with real operations.
Trigger with "clickhouse hello world", "first clickhouse table",
"clickhouse quick start", "create clickhouse table", "clickhouse example".
|
| allowed-tools | Read, Write, Edit, Bash(npm:*), Bash(node:*) |
| version | 1.7.0 |
| license | MIT |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
| tags | ["saas","database","analytics","clickhouse","olap"] |
| compatibility | Designed for Claude Code |
ClickHouse Hello World
Overview
Create a MergeTree table, insert rows with JSONEachRow, and run your first
analytical query -- all using the official @clickhouse/client. This is the
smoke test that proves your connection works and teaches the four MergeTree
concepts (ORDER BY, PARTITION BY, TTL, LowCardinality) reused in every
real schema.
Prerequisites
@clickhouse/client installed and connected (see the clickhouse-install-auth
skill for connection setup).
- A reachable ClickHouse server (local Docker, ClickHouse Cloud, or self-hosted)
with
CLICKHOUSE_HOST / CLICKHOUSE_USER / CLICKHOUSE_PASSWORD set as
environment variables.
Instructions
Step 1: Create a MergeTree Table
import { createClient } from '@clickhouse/client';
const client = createClient({
url: process.env.CLICKHOUSE_HOST ?? 'http://localhost:8123',
username: process.env.CLICKHOUSE_USER ?? 'default',
password: process.env.CLICKHOUSE_PASSWORD ?? '',
});
await client.command({
query: `
CREATE TABLE IF NOT EXISTS events (
event_id UUID DEFAULT generateUUIDv4(),
event_type LowCardinality(String),
user_id UInt64,
payload String,
created_at DateTime DEFAULT now()
)
ENGINE = MergeTree()
ORDER BY (event_type, created_at)
PARTITION BY toYYYYMM(created_at)
TTL created_at + INTERVAL 90 DAY
`,
});
console.log('Table "events" created.');
Key concepts: