Drop Table (DROP TABLE)
Usage
The DROP TABLE command is used to delete a regular table in the Lakehouse. After execution, the table and its data will be removed.
Syntax
Parameter Description
| Parameter | Description |
|---|---|
IF EXISTS | Optional. If the specified table does not exist, no error is raised |
schema_name | Optional. The name of the schema. If not specified, the current schema is used by default |
table_name | The name of the table to drop |
Examples
Example 1: Drop a table in the current schema
Example 2: Safe drop (no error if the table does not exist)
Example 3: Drop a table in a specified schema
Example 4: Drop and restore
Notes
-
Object Type Matching:
DROP TABLEcan only drop regular tables. To drop a dynamic table, useDROP DYNAMIC TABLE. To drop a materialized view, useDROP MATERIALIZED VIEW. Using the wrong command will result in an error. -
Data Recovery: After dropping a table, it can be restored via
UNDROP TABLEwithin thedata_retention_daysretention period. A table with the same name must not exist at the time of restoration. -
Dependent Objects: Before dropping a table, confirm whether other objects depend on it:
- Views referencing the table will become invalid
- Dynamic tables that use the table as a source will fail to refresh
- Table Streams bound to the table will be unable to consume
- Downstream ETL tasks that depend on the table will fail to execute
-
Dropping a Source Table Invalidates Associated Streams: When
DROP TABLEremoves a source table, all Table Streams based on that table will immediately become invalid and can no longer consume change data. If you need to preserve Stream data, consume all changes in the Stream before dropping the source table. -
Cascading Deletion: Use
DROP SCHEMAto cascade-delete all tables under a schema without dropping them individually.
