Supported Versions: Current (17) / 16 / 15 / 14 / 13
Development Versions: devel
Unsupported versions: 12 / 11 / 10 / 9.6 / 9.5 / 9.4 / 9.3 / 9.2 / 9.1 / 9.0 / 8.4 / 8.3 / 8.2 / 8.1 / 8.0 / 7.4 / 7.3 / 7.2 / 7.1
This documentation is for an unsupported version of PostgreSQL.
You may want to view the same page for the current version, or one of the other supported versions listed above instead.

DROP TABLE

Name

DROP TABLE  --  remove a table

Synopsis

DROP TABLE name [, ...]
  

Inputs

name

The name of an existing table to drop.

Outputs

DROP

The message returned if the command completes successfully.

ERROR: table "name" does not exist

If the specified table does not exist in the database.

Description

DROP TABLE removes tables from the database. Only its owner may destroy a table. A table may be emptied of rows, but not destroyed, by using DELETE.

If a table being destroyed has secondary indexes on it, they will be removed first. The removal of just a secondary index will not affect the contents of the underlying table.

Notes

Refer to CREATE TABLE and ALTER TABLE for information on how to create or modify tables.

Usage

To destroy two tables, films and distributors:

DROP TABLE films, distributors;
   

Compatibility

SQL92

SQL92 specifies some additional capabilities for DROP TABLE:

DROP TABLE table { RESTRICT | CASCADE }
   
RESTRICT

Ensures that only a table with no dependent views or integrity constraints can be destroyed.

CASCADE

Any referencing views or integrity constraints will also be dropped.

Tip: At present, to remove a referenced view you must drop it explicitly.