Deleting a Table

Function

This statement is used to delete tables.

Syntax

1
DROP TABLE [IF EXISTS] [db_name.]table_name;

Keyword

DROP: Delete a table.
  • If the table is stored in OBS, only the metadata is deleted. The data stored on OBS is not deleted.
  • If the table is stored in DLI, the data and the corresponding metadata are all deleted.

Precautions

The to-be-deleted table must exist in the current database. Otherwise, an error is reported. To avoid this error, add IF EXISTS in this statement.

Example

To delete a table named student in the current database, run the following statement:

1
DROP TABLE IF EXISTS student;