]> granicus.if.org Git - postgresql/blob - doc/src/sgml/ref/drop_table.sgml
52189f5e7d32724c27558f9bb2bd46d9e9760d0e
[postgresql] / doc / src / sgml / ref / drop_table.sgml
1 <!--
2 $PostgreSQL: pgsql/doc/src/sgml/ref/drop_table.sgml,v 1.21 2003/11/29 19:51:38 pgsql Exp $
3 PostgreSQL documentation
4 -->
5
6 <refentry id="SQL-DROPTABLE">
7  <refmeta>
8   <refentrytitle id="SQL-DROPTABLE-TITLE">DROP TABLE</refentrytitle>
9   <refmiscinfo>SQL - Language Statements</refmiscinfo>
10  </refmeta>
11
12  <refnamediv>
13   <refname>DROP TABLE</refname>
14   <refpurpose>remove a table</refpurpose>
15  </refnamediv>
16
17  <indexterm zone="sql-droptable">
18   <primary>DROP TABLE</primary>
19  </indexterm>
20
21  <refsynopsisdiv>
22 <synopsis>
23 DROP TABLE <replaceable class="PARAMETER">name</replaceable> [, ...] [ CASCADE | RESTRICT ]
24 </synopsis>
25  </refsynopsisdiv>
26  
27  <refsect1>
28   <title>Description</title>
29
30   <para>
31    <command>DROP TABLE</command> removes tables from the database.
32    Only its owner may destroy a table.  To empty a table of rows,
33    without destroying the table, use <command>DELETE</command>.
34   </para>
35
36   <para>
37    <command>DROP TABLE</command> always removes any indexes, rules,
38    triggers, and constraints that exist for the target table.
39    However, to drop a table that is referenced by a foreign-key
40    constraint of another table, <literal>CASCADE</> must be
41    specified. (<literal>CASCADE</> will remove the foreign-key
42    constraint, not the other table entirely.)
43   </para>
44  </refsect1>
45   
46  <refsect1>
47   <title>Parameters</title>
48
49   <variablelist>
50    <varlistentry>
51     <term><replaceable class="PARAMETER">name</replaceable></term>
52     <listitem>
53      <para>
54       The name (optionally schema-qualified) of the table to drop.
55      </para>
56     </listitem>
57    </varlistentry>
58
59    <varlistentry>
60     <term><literal>CASCADE</literal></term>
61     <listitem>
62      <para>
63       Automatically drop objects that depend on the table (such as
64       views).
65      </para>
66     </listitem>
67    </varlistentry>
68
69    <varlistentry>
70     <term><literal>RESTRICT</literal></term>
71     <listitem>
72      <para>
73       Refuse to drop the table if any objects depend on it.  This is
74       the default.
75      </para>
76     </listitem>
77    </varlistentry>
78   </variablelist>
79  </refsect1>
80
81  <refsect1>
82   <title>Examples</title>
83
84   <para>
85    To destroy two tables, <literal>films</literal> and 
86    <literal>distributors</literal>:
87
88 <programlisting>
89 DROP TABLE films, distributors;
90 </programlisting>
91   </para>
92  </refsect1>
93  
94  <refsect1>
95   <title>Compatibility</title>
96
97   <para>
98    This command conforms to the SQL standard.
99   </para>
100  </refsect1>
101
102  <refsect1>
103   <title>See Also</title>
104
105   <simplelist type="inline">
106    <member><xref linkend="sql-altertable" endterm="sql-altertable-title"></member>
107    <member><xref linkend="sql-createtable" endterm="sql-createtable-title"></member>
108   </simplelist>
109  </refsect1>
110
111 </refentry>
112
113 <!-- Keep this comment at the end of the file
114 Local variables:
115 mode: sgml
116 sgml-omittag:nil
117 sgml-shorttag:t
118 sgml-minimize-attributes:nil
119 sgml-always-quote-attributes:t
120 sgml-indent-step:1
121 sgml-indent-data:t
122 sgml-parent-document:nil
123 sgml-default-dtd-file:"../reference.ced"
124 sgml-exposed-tags:nil
125 sgml-local-catalogs:"/usr/lib/sgml/catalog"
126 sgml-local-ecat-files:nil
127 End:
128 -->