Updated on 2024-05-21 GMT+08:00

DROP TABLE

Function

Deletes a table.

Precautions

  • After DROP TABLE deletes the table, the indexes depending on the table are deleted, and the functions and stored procedures that need to use this table cannot be executed. Deleting a partitioned table also deletes all partitions in the table.
  • The owner of a table, the owner of the schema of the table, users granted with the DROP permission on the table, or users granted with the DROP ANY TABLE permission can delete the specified table. The system administrator has the permission to delete the specified table by default.

Syntax

DROP TABLE [ IF EXISTS ] 
    { [schema.]table_name } [, ...] [ CASCADE | RESTRICT ] [ PURGE ];

Parameters

  • IF EXISTS

    Reports a notice instead of an error if the specified table does not exist.

  • schema

    Specifies the schema name.

  • table_name

    Specifies the table name.

  • CASCADE | RESTRICT
    • CASCADE: allows to cascadingly delete the objects (such as views) that depend on the table.
    • RESTRICT: refuses to delete the table if any objects depend on it. This is the default action.
  • PURGE

    Specifies that even if the recycle bin function is enabled, the table is physically dropped instead of being moved to the recycle bin when you use DROP TABLE to delete tables.

Examples

See Examples in section "CREATE TABLE."

Helpful Links

ALTER TABLE and CREATE TABLE