2 doc/src/sgml/ref/drop_table.sgml
3 PostgreSQL documentation
6 <refentry id="SQL-DROPTABLE">
8 <refentrytitle>DROP TABLE</refentrytitle>
9 <manvolnum>7</manvolnum>
10 <refmiscinfo>SQL - Language Statements</refmiscinfo>
14 <refname>DROP TABLE</refname>
15 <refpurpose>remove a table</refpurpose>
18 <indexterm zone="sql-droptable">
19 <primary>DROP TABLE</primary>
24 DROP TABLE [ IF EXISTS ] <replaceable class="PARAMETER">name</replaceable> [, ...] [ CASCADE | RESTRICT ]
29 <title>Description</title>
32 <command>DROP TABLE</command> removes tables from the database.
33 Only the table owner, the schema owner, and superuser can drop a
34 table. To empty a table of rows
35 without destroying the table, use <xref linkend="sql-delete">
36 or <xref linkend="sql-truncate">.
40 <command>DROP TABLE</command> always removes any indexes, rules,
41 triggers, and constraints that exist for the target table.
42 However, to drop a table that is referenced by a view or a foreign-key
43 constraint of another table, <literal>CASCADE</> must be
44 specified. (<literal>CASCADE</> will remove a dependent view entirely,
45 but in the foreign-key case it will only remove the foreign-key
46 constraint, not the other table entirely.)
51 <title>Parameters</title>
55 <term><literal>IF EXISTS</literal></term>
58 Do not throw an error if the table does not exist. A notice is issued
65 <term><replaceable class="PARAMETER">name</replaceable></term>
68 The name (optionally schema-qualified) of the table to drop.
74 <term><literal>CASCADE</literal></term>
77 Automatically drop objects that depend on the table (such as
84 <term><literal>RESTRICT</literal></term>
87 Refuse to drop the table if any objects depend on it. This is
96 <title>Examples</title>
99 To destroy two tables, <literal>films</literal> and
100 <literal>distributors</literal>:
103 DROP TABLE films, distributors;
104 </programlisting></para>
108 <title>Compatibility</title>
111 This command conforms to the SQL standard, except that the standard only
112 allows one table to be dropped per command, and apart from the
113 <literal>IF EXISTS</> option, which is a <productname>PostgreSQL</>
119 <title>See Also</title>
121 <simplelist type="inline">
122 <member><xref linkend="sql-altertable"></member>
123 <member><xref linkend="sql-createtable"></member>