Updated on 2024-07-04 GMT+08:00

Deleting a Table

Function

This statement is used to delete tables.

Syntax

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

Keywords

  • 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.

Parameters

Table 1 Parameters

Parameter

Description

db_name

Database name, which consists of letters, digits, and underscores (_). The value cannot contain only digits or start with a digit or underscore (_).

table_name

Table name

Precautions

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

Example

  1. Create a table. For details, see Creating an OBS Table or Creating a DLI Table.
  2. Run the following statement to delete table test from the current database:
    1
    DROP TABLE IF EXISTS test;