]> begriffs open source - ai-pg/blob - full-docs/txt/sql-droptable.txt
Convert HTML docs to more streamlined TXT
[ai-pg] / full-docs / txt / sql-droptable.txt
1
2 DROP TABLE
3
4    DROP TABLE — remove a table
5
6 Synopsis
7
8 DROP TABLE [ IF EXISTS ] name [, ...] [ CASCADE | RESTRICT ]
9
10 Description
11
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 or TRUNCATE.
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
23 Parameters
24
25    IF EXISTS
26           Do not throw an error if the table does not exist. A notice is
27           issued in this case.
28
29    name
30           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), and in turn all objects that depend on those objects
35           (see Section 5.15).
36
37    RESTRICT
38           Refuse to drop the table if any objects depend on it. This is
39           the default.
40
41 Examples
42
43    To destroy two tables, films and distributors:
44 DROP TABLE films, distributors;
45
46 Compatibility
47
48    This command conforms to the SQL standard, except that the standard
49    only allows one table to be dropped per command, and apart from the IF
50    EXISTS option, which is a PostgreSQL extension.
51
52 See Also
53
54    ALTER TABLE, CREATE TABLE