Using Clickhouse Commands
This section describes common ClickHouse commands. After installing the ClickHouse client and loading environment variables, run the following commands to perform operations:
- Connect to the ClickHouse cluster.
Use the following command to connect to a normal cluster.
./clickhouse client --host Private IP address of the cluster --port Port --user admin --password Password
For details about the security cluster connection command. For details, see Connecting to a Security Cluster.
./clickhouse client --host Private IP address of the cluster --port port --user admin --password Password --secure --config-file /root/config.xml
- Create a database.
create database demo;
- Use the database.
use demo;
- Check the database in use.
select currentDatabase();
- Create a table.
create table demo_t(uid Int32,name String,age UInt32,gender String)engine = TinyLog;
- View the table structure.
desc demo_t;
- Insert data.
insert into demo_t values(1,'Candy','23','M'),(2,'cici','33','F');
- View the table.
select * from demo_t;
- View the database and table.
- Viewing the database
show databases;
- Viewing the table
show tables;
- Viewing the database
- Delete the database and table.
- Deleting the table
drop table demo_t;
- Before deleting a data table, check whether the data table is in use to avoid unnecessary troubles.
- After a data table is deleted, it can be restored within 24 hours. The restoration command is as follows:
set allow_experimental_undrop_table_query = 1;
UNDROP TABLE Data table name;
- Deleting the database
drop database demo;
- Deleting the table
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot