You need to enable JavaScript to run this app.
ByteHouse Cloud Data Warehouse Version

ByteHouse Cloud Data Warehouse Version

Copy page
Download PDF
DDL
Delete statement (DROP)
Copy page
Download PDF
Delete statement (DROP)

Delete database (DROP DATABASE)

Delete a database.
Syntax

DROP DATABASE [IF EXISTS] [databaseIdentifier]

Example

-- create database 
CREATE DATABASE example_db 

-- delete database 
DROP DATABASE example_db

Delete table (DROP TABLE)

Delete a table.
Syntax

DROP TABLE [IF EXISTS] [tableIdentifier]

Example

-- 1. create table 
CREATE TABLE `example_table` 
( 
    `order_by_column` String 
) 
ENGINE = `CnchMergeTree` 
ORDER BY (`order_by_column`) 

-- 2. delete table 
DROP TABLE example_table

Delete view (DROP VIEW)

Delete a view. Views can also be deleted using the DROP TABLE command, but DROP VIEW checks whether [db.]name is a view.
Syntax

DROP VIEW [IF EXISTS] [db.]name

Delete dictionary (DROP DICTIONARY)

Delete a dictionary.
Syntax

DROP DICTIONARY [IF EXISTS] [db.]name

TRUNCATE TABLE

Remove all data in a table.

warning

Data deleted by the TRUNCATE operation cannot be restored. Please operate with caution.

Syntax

TRUNCATE TABLE [IF EXISTS] [tableIdentifier]

Example

TRUNCATE TABLE IF EXISTS example_table

FAQs: If you mistakenly delete a table using DROP TABLE, can it be restored?

If you mistakenly delete a table using DROP TABLE, you can restore it with UNDROP TABLE. This method is only applicable for restoring deletions performed by DROP TABLE, and the validity period is limited. Currently, you can restore tables deleted within the past two days at most, which can be used for temporary loss prevention due to accidental operations. It is strongly recommended to use the backup restore function. For details, see backup restore.
Examples are as follows:

# Delete table, but discover the table was mistakenly deleted 
DROP TABLE db_name.table_name; 

# Use UNDROP TABLE to restore the table 
UNDROP TABLE db_name.table_name; 

# Query data to verify whether the restoration was successful 
SELECT count() FROM db_name.table_name;
Last updated: 2026.03.31 10:31:07