Help Center/
CloudTable Service/
Developer Guide/
ClickHouse Application Development Guide/
SQL Syntax/
DROP
Updated on 2024-04-29 GMT+08:00
DROP
This section describes the basic syntax and usage of the SQL statement for deleting a ClickHouse table.
Basic Syntax
DROP [TEMPORARY] TABLE [IF EXISTS] [database_name.]name [ON CLUSTER cluster] [SYNC]
Examples:
- Delete the t1 table.
drop table t1 SYNC;
- When you delete a replication table, create a path on ZooKeeper to store related data. The default library engine of ClickHouse is the atomic database engine. After a table in the atomic database is deleted, it is not deleted immediately but deleted 24 hours later. To resolve this issue, when deleting a table, add the SYNC field to the deletion command, for example, drop table t1 SYNC;.
- This issue does not occur when a local or distributed table is deleted. The SYNC field is not required in your deletion command, for example, drop table t1;.
- If the table creation statement contains ON CLUSTER ClickHouse cluster name, run the following command to delete the table:
drop table Table name ON CLUSTER default_cluster;
- If the table creation statement does not contain ON CLUSTER ClickHouse cluster name, run the following command to delete the table:
drop table Table name;
- 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;
Parent topic: SQL Syntax
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.
The system is busy. Please try again later.
For any further questions, feel free to contact us through the chatbot.
Chatbot