clickhouse-client
clickhouse-client
.The ClickHouse® Client is a command line based program that will be familiar to SQL based users. For more information on clickhouse-client
, see the ClickHouse Documentation Command-Line Client page.
The access points for your Altinity.Cloud ClickHouse cluster can be viewed through the Cluster Access Point.
How to install clickhouse-client on Linux
As of this document’s publication, the most recent version of clickhouse-client
is
23.9. Here is the install procedure for DEB packages:
sudo apt-get install -y apt-transport-https ca-certificates dirmngr
GNUPGHOME=$(mktemp -d)
sudo GNUPGHOME="$GNUPGHOME" gpg --no-default-keyring --keyring /usr/share/keyrings/clickhouse-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 8919F6BD2B48D754
sudo rm -r "$GNUPGHOME"
sudo chmod +r /usr/share/keyrings/clickhouse-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/clickhouse-keyring.gpg] https://packages.clickhouse.com/deb stable main" | sudo tee \
/etc/apt/sources.list.d/clickhouse.list
sudo apt-get update
sudo apt-get install -y clickhouse-client
See the ClickHouse documentation for install instructions for the latest version or for other platforms.
How to install clickhouse-client on Mac
Installation of the macOS ClickHouse client uses the Brew package installer. Enter each of the four lines in turn. (The final step starts ClickHouse.)
brew tap altinity/clickhouse
brew tap-info --json altinity/clickhouse
brew install clickhouse
brew services start clickhouse
Logging on to your cluster
From the Connection Details, copy and paste the text string to your Ubuntu terminal:
clickhouse-client -h maddie.xxx.altinity.cloud --port 9440 -s --user admin --password xxx
You’ll be in ClickHouse interactive mode:
ClickHouse client version 23.9.1.1854 (official build).
Connecting to maddie.xxx.altinity.cloud:9440 as user admin.
Connected to ClickHouse server version 23.3.13 revision 54462.
ClickHouse server version is older than ClickHouse client. It may indicate that the server is out of date and can be upgraded.
maddie :)
ClickHouse query examples
At the ClickHouse prompt, enter the query command show tables:
maddie :) show tables
SHOW TABLES
Query id: c319298f-2f28-48fe-96ca-ce59aacdbc43
┌─name─────────┐
│ events │
│ events_local │
└──────────────┘
2 rows in set. Elapsed: 0.080 sec.
At the ClickHouse prompt, enter the query select * from events:
maddie :) select * from events
SELECT *
FROM events
Query id: 0e4d08b3-a52d-4a03-917d-226c6a2b00ac
┌─event_date─┬─event_type─┬─article_id─┬─title───┐
│ 2023-01-04 │ 1 │ 13 │ Example │
│ 2023-01-10 │ 1 │ 13 │ Example │
│ 2023-01-10 │ 1 │ 14 │ Example │
└────────────┴────────────┴────────────┴─────────┘
3 rows in set. Elapsed: 0.073 sec.
Enter the exit command to return to the command line:
maddie :) exit
Bye.