This page in other versions: 8.4 / 9.0 / 9.1 / 9.2 / 9.3  |  Development versions: devel / 9.4  |  Unsupported versions: 7.1 / 7.2 / 7.3 / 7.4 / 8.0 / 8.1 / 8.2 / 8.3

DROP TABLE

Name

DROP TABLE  --  remove a table

Synopsis

DROP TABLE name [, ...] [ CASCADE | RESTRICT ]

  

Inputs

name

The name (optionally schema-qualified) of an existing table to drop.

CASCADE

Automatically drop objects that depend on the table (such as views).

RESTRICT

Refuse to drop the table if there are any dependent objects. This is the default.

Outputs

DROP TABLE

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.

DROP TABLE always removes any indexes, rules, triggers, and constraints that exist for the target table. However, to drop a table that is referenced by a foreign-key constraint of another table, CASCADE must be specified. (CASCADE will remove the foreign-key constraint, not the other table itself.)

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group