Product Documentation

SQL Reference Guide

Previous Topic

Next Topic

DROP TABLE

Description

Deletes the specified table.

Syntax

DROP TABLE [IF EXISTS] [owner_name.]table_name ;

Notes

  • If owner_name is specified and is different from the name of the user executing the statement, then the user must have DBA privileges.
  • When a table is dropped, the indexes on the table and the privileges associated with the table are dropped automatically.
  • Views dependent on the dropped table are not automatically dropped, but become invalid.
  • If the table is part of another table’s referential constraint (if the table is named in another table’s REFERENCES clause), the DROP TABLE statement fails. Use the ALTER TABLE statement to delete any referential constraints that refer to the table before issuing the DROP TABLE statement.
  • IF EXISTS avoids failure by attempting to drop the table only if a table of that name already exists.

Example

DROP TABLE customer ;

Authorization

The user executing this statement must have any of the following privileges:

  • DBA privilege.
  • Ownership of the table.

    SQL Compliance

    SQL-92, ODBC Minimum SQL grammar

    Environment

    Embedded SQL, interactive SQL, ODBC applications

    Related Statements

    CREATE TABLE

TOCIndex