1DROP TABLE() SQL Commands DROP TABLE()
2
3
4
6 DROP TABLE - remove a table
7
8
10 DROP TABLE [ IF EXISTS ] name [, ...] [ CASCADE | RESTRICT ]
11
12
14 DROP TABLE removes tables from the database. Only its owner may
15 destroy a table. To empty a table of rows without destroying the table,
16 use DELETE [delete(7)] or TRUNCATE [truncate(l)].
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
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
41 To destroy two tables, films and distributors:
42
43 DROP TABLE films, distributors;
44
45
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
52 ALTER TABLE [alter_table(7)], CREATE TABLE [create_table(l)]
53
54
55
56SQL - Language Statements 2008-06-08 DROP TABLE()