1<!--
2doc/src/sgml/ref/drop_database.sgml
3PostgreSQL documentation
4-->
5
6<refentry id="SQL-DROPDATABASE">
7 <indexterm zone="sql-dropdatabase">
8  <primary>DROP DATABASE</primary>
9 </indexterm>
10
11 <refmeta>
12  <refentrytitle>DROP DATABASE</refentrytitle>
13  <manvolnum>7</manvolnum>
14  <refmiscinfo>SQL - Language Statements</refmiscinfo>
15 </refmeta>
16
17 <refnamediv>
18  <refname>DROP DATABASE</refname>
19  <refpurpose>remove a database</refpurpose>
20 </refnamediv>
21
22 <refsynopsisdiv>
23<synopsis>
24DROP DATABASE [ IF EXISTS ] <replaceable class="PARAMETER">name</replaceable>
25</synopsis>
26 </refsynopsisdiv>
27
28 <refsect1>
29  <title>Description</title>
30
31  <para>
32   <command>DROP DATABASE</command> drops a database. It removes the
33   catalog entries for the database and deletes the directory
34   containing the data.  It can only be executed by the database owner.
35   Also, it cannot be executed while you or anyone else are connected
36   to the target database.  (Connect to <literal>postgres</literal> or any
37   other database to issue this command.)
38  </para>
39
40  <para>
41   <command>DROP DATABASE</command> cannot be undone.  Use it with care!
42  </para>
43 </refsect1>
44
45 <refsect1>
46  <title>Parameters</title>
47
48  <variablelist>
49   <varlistentry>
50    <term><literal>IF EXISTS</literal></term>
51    <listitem>
52     <para>
53      Do not throw an error if the database does not exist. A notice is issued
54      in this case.
55     </para>
56    </listitem>
57   </varlistentry>
58
59   <varlistentry>
60    <term><replaceable class="PARAMETER">name</replaceable></term>
61    <listitem>
62     <para>
63      The name of the database to remove.
64     </para>
65    </listitem>
66   </varlistentry>
67  </variablelist>
68 </refsect1>
69
70 <refsect1>
71  <title>Notes</title>
72
73   <para>
74    <command>DROP DATABASE</> cannot be executed inside a transaction
75    block.
76   </para>
77
78  <para>
79   This command cannot be executed while connected to the target
80   database. Thus, it might be more convenient to use the program
81   <xref linkend="app-dropdb"> instead,
82   which is a wrapper around this command.
83  </para>
84 </refsect1>
85
86 <refsect1>
87  <title>Compatibility</title>
88
89  <para>
90   There is no <command>DROP DATABASE</command> statement in the SQL standard.
91  </para>
92 </refsect1>
93
94 <refsect1>
95  <title>See Also</title>
96
97  <simplelist type="inline">
98   <member><xref linkend="sql-createdatabase"></member>
99  </simplelist>
100 </refsect1>
101</refentry>
102