Updated on 2023-03-06 GMT+08:00

Deleting a Table

Function

This statement is used to delete tables.

Syntax

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

Keyword

  • 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 Parameter description

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 in 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;