DROP TABLE

更新时间:
复制 MD 格式

This topic describes the syntax and usage of the DROP TABLE statement.

Syntax

DROP TABLE [ IF EXISTS ] table_name [, ...];
Note

DROP TABLE supports dropping multiple tables in a single statement.

The following table describes the parameters.

Parameter

Description

IF EXISTS

  • If you specifyIF EXISTS, the statement succeeds even if the table does not exist.

  • If you do not specify IF EXISTS, the system returns an ERROR: table "non_exist_table" does not exist error if the target table does not exist.

table_name

The name of the table to drop.

Example

The following statement drops a table named holo_test:

DROP TABLE holo_test;

Drop a table using HoloWeb

HoloWeb provides a visual interface to drop a table without writing SQL statements. Follow these steps:

  1. Go to the HoloWeb console. Connect to HoloWeb to run queries.

  2. In the top menu bar of the HoloWeb page, click Metadata Management.

  3. On the Metadata Management page, in the Instances Connected list on the left, right-click the table to drop and select Delete Table.

  4. In the Delete Table dialog box, click OK.

FAQ

  • Problem

    The operation fails with the following error: ERROR: cannot drop table xxx because other objects depend on it. Detail: view xxx depends on table xxx. Hint: Use DROP ... CASCADE to drop the dependent objects too..

  • Possible cause

    The table cannot be dropped because a view depends on it.

  • Solution

    Run the following statement to perform a cascade drop, which drops the table along with any dependent objects, such as views.

    DROP TABLE [ IF EXISTS ] <table_name> [, ...] CASCADE;