DROP TABLE
The DROP TABLE statement drops a non-partitioned table or a partitioned table.
Usage notes
-
Use caution when dropping a table. A dropped table can only be restored if backup and restore is enabled for the project and the table is within the data retention period. Restoration requires local backup to be configured.
-
Dropping a table reduces the storage usage of the MaxCompute project.
Syntax
DROP TABLE [IF EXISTS] <table_name>; Parameters
|
Parameter |
Required |
Description |
|
IF EXISTS |
No |
Without IF EXISTS, attempting to drop a non-existent table returns an exception. With IF EXISTS, the statement succeeds even if the table does not exist. |
|
table_name |
Yes |
The name of the table to drop. |
Examples
-- Drop the sale_detail table. The statement succeeds regardless of whether the table exists.
DROP TABLE IF EXISTS sale_detail; Related commands
CREATE TABLE: Creates a non-partitioned table, a partitioned table, an external table, or a clustered table.
ALTER TABLE: Alters a table.
TRUNCATE TABLE: Removes all rows from a specified table.
DESC TABLE/VIEW: Describes an internal table, view, materialized view, external table, clustered table, or transactional table.
SHOW: Shows the DDL statement for a table, lists all tables and views in a project, or lists all partitions in a partitioned table.