DROP TABLE
Go Up to Statement and Function Reference (Language Reference Guide)
Removes a table from a database. Available in gpre, DSQL, and isql.
DROP TABLE name;
- Important: In SQL statements passed to DSQL, omit the terminating semicolon. In embedded applications written in C and C++, and in
isql, the semicolon is a terminating symbol for the statement, so it must be included.
| Argument | Description |
|---|---|
|
<name> |
Name of an existing table |
Description: DROP TABLE removes the data, metadata, and indexes of a table from a database. It also drops any triggers that reference the table.
A table referenced in a SQL expression, a view, integrity constraint, or stored procedure cannot be dropped. A table used by an active transaction is not dropped until it is free.
- Note: When used to drop an external table, DROP TABLE only removes the table definition from the database. The external file is not deleted.
A table can be dropped by its creator, the SYSDBA user, or any user with operating system root privileges.
Example: The following embedded SQL statement drops a table:
EXEC SQL
DROP TABLE COUNTRY;