Drops a non-partitioned table or a partitioned table.

Usage notes

  • Before you drop a table, confirm that the table can be dropped. Proceed with caution. If you accidentally drop a table, you can restore the table if the backup and restoration feature is enabled for the project and the table is dropped within the backup data retention period specified for the project. For more information about the backup and restoration feature, see Backup and restoration.
  • After you drop a table, the volume of stored data in a MaxCompute project decreases.

Syntax

drop table [if exists] <table_name>; 

Parameters

  • if exists: optional. If you do not specify the if exists parameter and the table that you want to drop does not exist, an error is returned. If you specify the if exists parameter, a success message is returned regardless of whether the table that you want to drop exists.
  • table_name: required. The name of the table that you want to drop.

Examples

-- Drop the sale_detail table. A success message is returned regardless of whether the sale_detail table exists. 
drop table if exists sale_detail; 

Related statements

  • CREATE TABLE: Creates a non-partitioned table, a partitioned table, an external table, or a clustered table.
  • ALTER TABLE: Alters information about a table.
  • TRUNCATE: Clears the data in a specified table.
  • DESC TABLE/VIEW: Views the information about internal tables, views, materialized views, external tables, clustered tables, and transactional tables of a MaxCompute project.
  • SHOW: Views the SQL DDL statement that is used to create a table, views the information about all tables and views in a project, or views the information about all partitions in a table.