Previous Next JavaScript must be enabled to correctly display this content

## DROP TABLE Statement

The drop table statement removes the specified table and all its associated indexes from the database.

Syntax

    drop_table_statement ::= DROP TABLE [IF EXISTS] name_path

Semantics

IF EXISTS

  By default, if the named table does not exist then this statement fails. If the optional IF EXISTS is specified and the table does not exist then no error is reported.

IDENTITY

  When a table with an identity column is dropped, the associated sequence generator is also removed.

Example 5-31 Drop Table

    CREATE TABLE DROPTEST (id INTEGER, name STRING, PRIMARY KEY(id))

    DROP TABLE DROPTEST

You cannot drop a parent table if there are child tables to it. To drop a parent table, first drop all of its child tables. Otherwise, the DROP statement results in an error as shown below.

    drop table users

Output:

    Error handling command drop table users: Error: User error in query:
    DROP TABLE failed for table users:
    Cannot remove table users, it is still referenced by child table