Skip to main content

DROP TABLE

Description

This statement is used to delete a table from seekdb.

Syntax

DROP {TABLE | TABLES} [TEMPORARY] [IF EXISTS]
table_name [,table_name]...
[RESTRICT | CASCADE]

Parameters

ParameterDescription
table_nameSpecifies the name of the table to be deleted. When deleting multiple tables, separate the table names with commas.
TEMPORARYSpecifies that the table is a temporary table.
IF EXISTSIf you specify IF EXISTS, no error will be returned even if the table does not exist. If you do not specify this option, an error will be returned.
RESTRICT | CASCADEUsed in scenarios where tables are migrated from other databases to seekdb.
Note This parameter is not supported in the current version. If specified, it will be parsed and ignored.

Examples

  • Delete the test1 table by specifying IF EXISTS.

    DROP TABLE IF EXISTS test1;
    Query OK, 0 rows affected (0.001 sec)
  • Delete the test1 and test2 tables by specifying IF EXISTS.

    DROP TABLES IF EXISTS test1,test2;
    Query OK, 0 rows affected (0.001 sec)
  • Delete multiple tables without specifying IF EXISTS. An error will be returned if any of the tables do not exist.

    DROP TABLES test1,test2;
    ERROR 1051 (42S02): Unknown table 'test.test2'
  • Delete the temporary table tset3.

    DROP TEMPORARY TABLE test3;
    Query OK, 0 rows affected (0.001 sec)