1DROP TABLE(7)                    SQL Commands                    DROP TABLE(7)
2
3
4

NAME

6       DROP TABLE - remove a table
7
8

SYNOPSIS

10       DROP TABLE [ IF EXISTS ] name [, ...] [ CASCADE | RESTRICT ]
11
12

DESCRIPTION

14       DROP TABLE removes tables from the database.  Only its owner can drop a
15       table. To empty a table of  rows  without  destroying  the  table,  use
16       DELETE [delete(7)] or TRUNCATE [truncate(7)].
17
18       DROP TABLE always removes any indexes, rules, triggers, and constraints
19       that exist for the target table.  However, to drop a table that is ref‐
20       erenced by a view or a foreign-key constraint of another table, CASCADE
21       must be specified. (CASCADE will remove a dependent view entirely,  but
22       in the foreign-key case it will only remove the foreign-key constraint,
23       not the other table entirely.)
24

PARAMETERS

26       IF EXISTS
27              Do not throw an error if the table does not exist. A  notice  is
28              issued in this case.
29
30       name   The name (optionally schema-qualified) of the table to drop.
31
32       CASCADE
33              Automatically  drop  objects  that  depend on the table (such as
34              views).
35
36       RESTRICT
37              Refuse to drop the table if any objects depend on  it.  This  is
38              the default.
39

EXAMPLES

41       To destroy two tables, films and distributors:
42
43       DROP TABLE films, distributors;
44
45

COMPATIBILITY

47       This  command  conforms  to  the SQL standard, except that the standard
48       only allows one table to be dropped per command, and apart from the  IF
49       EXISTS option, which is a PostgreSQL extension.
50

SEE ALSO

52       ALTER TABLE [alter_table(7)], CREATE TABLE [create_table(7)]
53
54
55
56SQL - Language Statements         2014-02-17                     DROP TABLE(7)
Impressum