1DROP TABLE(7)            PostgreSQL 12.2 Documentation           DROP TABLE(7)
2
3
4

NAME

6       DROP_TABLE - remove a table
7

SYNOPSIS

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

DESCRIPTION

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

PARAMETERS

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

EXAMPLES

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

COMPATIBILITY

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

SEE ALSO

51       ALTER TABLE (ALTER_TABLE(7)), CREATE TABLE (CREATE_TABLE(7))
52
53
54
55PostgreSQL 12.2                      2020                        DROP TABLE(7)
Impressum