]> granicus.if.org Git - postgresql/blob - doc/src/sgml/ref/drop_index.sgml
Trim trailing whitespace
[postgresql] / doc / src / sgml / ref / drop_index.sgml
1 <!--
2 doc/src/sgml/ref/drop_index.sgml
3 PostgreSQL documentation
4 -->
5
6 <refentry id="SQL-DROPINDEX">
7  <indexterm zone="sql-dropindex">
8   <primary>DROP INDEX</primary>
9  </indexterm>
10
11  <refmeta>
12   <refentrytitle>DROP INDEX</refentrytitle>
13   <manvolnum>7</manvolnum>
14   <refmiscinfo>SQL - Language Statements</refmiscinfo>
15  </refmeta>
16
17  <refnamediv>
18   <refname>DROP INDEX</refname>
19   <refpurpose>remove an index</refpurpose>
20  </refnamediv>
21
22  <refsynopsisdiv>
23 <synopsis>
24 DROP INDEX [ CONCURRENTLY ] [ IF EXISTS ] <replaceable class="PARAMETER">name</replaceable> [, ...] [ CASCADE | RESTRICT ]
25 </synopsis>
26  </refsynopsisdiv>
27
28  <refsect1>
29   <title>Description</title>
30
31   <para>
32    <command>DROP INDEX</command> drops an existing index from the database
33    system. To execute this command you must be the owner of
34    the index.
35   </para>
36  </refsect1>
37
38  <refsect1>
39   <title>Parameters</title>
40
41   <variablelist>
42    <varlistentry>
43     <term><literal>CONCURRENTLY</literal></term>
44     <listitem>
45      <para>
46       Drop the index without locking out concurrent selects, inserts, updates,
47       and deletes on the index's table.  A normal <command>DROP INDEX</>
48       acquires exclusive lock on the table, blocking other accesses until the
49       index drop can be completed.  With this option, the command instead
50       waits until conflicting transactions have completed.
51      </para>
52      <para>
53       There are several caveats to be aware of when using this option.
54       Only one index name can be specified, and the <literal>CASCADE</> option
55       is not supported.  (Thus, an index that supports a <literal>UNIQUE</> or
56       <literal>PRIMARY KEY</> constraint cannot be dropped this way.)
57       Also, regular <command>DROP INDEX</> commands can be
58       performed within a transaction block, but
59       <command>DROP INDEX CONCURRENTLY</> cannot.
60      </para>
61     </listitem>
62    </varlistentry>
63
64    <varlistentry>
65     <term><literal>IF EXISTS</literal></term>
66     <listitem>
67      <para>
68       Do not throw an error if the index does not exist. A notice is issued
69       in this case.
70      </para>
71     </listitem>
72    </varlistentry>
73
74    <varlistentry>
75     <term><replaceable class="PARAMETER">name</replaceable></term>
76     <listitem>
77      <para>
78       The name (optionally schema-qualified) of an index to remove.
79      </para>
80     </listitem>
81    </varlistentry>
82
83    <varlistentry>
84     <term><literal>CASCADE</literal></term>
85     <listitem>
86      <para>
87       Automatically drop objects that depend on the index,
88       and in turn all objects that depend on those objects
89       (see <xref linkend="ddl-depend">).
90      </para>
91     </listitem>
92    </varlistentry>
93
94    <varlistentry>
95     <term><literal>RESTRICT</literal></term>
96     <listitem>
97      <para>
98       Refuse to drop the index if any objects depend on it.  This is
99       the default.
100      </para>
101     </listitem>
102    </varlistentry>
103   </variablelist>
104  </refsect1>
105
106  <refsect1>
107   <title>Examples</title>
108
109   <para>
110    This command will remove the index <literal>title_idx</literal>:
111
112 <programlisting>
113 DROP INDEX title_idx;
114 </programlisting></para>
115  </refsect1>
116
117  <refsect1>
118   <title>Compatibility</title>
119
120   <para>
121    <command>DROP INDEX</command> is a
122    <productname>PostgreSQL</productname> language extension.  There
123    are no provisions for indexes in the SQL standard.
124   </para>
125  </refsect1>
126
127  <refsect1>
128   <title>See Also</title>
129
130   <simplelist type="inline">
131    <member><xref linkend="sql-createindex"></member>
132   </simplelist>
133  </refsect1>
134
135 </refentry>