Updated on 2022-12-07 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.

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 an OBS or DLI table, for example, student. For details, see Creating an OBS Table or Creating a DLI Table.
  2. Run the following statement to delete a table named student in the current database:
    1
    DROP TABLE IF EXISTS student;