dropdb.sgml 6.6 KB
Newer Older
1
<!--
2
$Header: /cvsroot/pgsql/doc/src/sgml/ref/dropdb.sgml,v 1.20 2003/03/18 22:19:46 petere Exp $
3
PostgreSQL documentation
4 5 6 7
-->

<refentry id="APP-DROPDB">
 <refmeta>
8 9
  <refentrytitle id="APP-DROPDB-TITLE"><application>dropdb</application></refentrytitle>
  <manvolnum>1</manvolnum>
10 11
  <refmiscinfo>Application</refmiscinfo>
 </refmeta>
12

13
 <refnamediv>
14
  <refname>dropdb</refname>
15
  <refpurpose>remove a <productname>PostgreSQL</productname> database</refpurpose>
16
 </refnamediv>
17

18
 <refsynopsisdiv>
19 20 21 22 23
  <cmdsynopsis>
   <command>dropdb</command>
   <arg rep="repeat"><replaceable>options</replaceable></arg>
   <arg choice="plain"><replaceable>dbname</replaceable></arg>
  </cmdsynopsis>
24
 </refsynopsisdiv>
25

26 27 28 29 30 31 32 33 34 35 36 37

 <refsect1>
  <title>Description</title>

  <para>
   <application>dropdb</application> destroys an existing
   <productname>PostgreSQL</productname> database.
   The user who executes this command must be a database
   superuser or the owner of the database.
  </para>

  <para>
38 39 40 41 42 43 44
   <application>dropdb</application> is a wrapper around the
   <acronym>SQL</acronym> command <xref linkend="SQL-DROPDATABASE"
   endterm="SQL-DROPDATABASE-title">.  Thus, there is nothing special
   about dropping databases via this or other methods. This means that
   a database server is running at the targeted host. Also, any
   default settings and environment variables used by the
   <application>libpq</application> front-end library do apply.
45 46 47 48 49
  </para>
 </refsect1>


 <refsect1>
P
Peter Eisentraut 已提交
50 51 52 53
  <title>Options</title>

  <para>
   <application>dropdb</> accepts the following command-line arguments:
54 55 56

    <variablelist>
     <varlistentry>
P
Peter Eisentraut 已提交
57
      <term><replaceable class="parameter">dbname</replaceable></term>
58 59
      <listitem>
       <para>
P
Peter Eisentraut 已提交
60 61 62
	Specifies the name of the database to be removed.  The database
	must be one of the existing <productname>PostgreSQL</productname> databases
	in this installation.
63 64 65 66 67
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
P
Peter Eisentraut 已提交
68 69
      <term><option>-e</></term>
      <term><option>--echo</></term>
70 71
      <listitem>
       <para>
P
Peter Eisentraut 已提交
72 73
        Echo the queries that <application>dropdb</application> generates
	and sends to the server.
74 75 76 77 78
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
P
Peter Eisentraut 已提交
79 80
      <term><option>-i</></term>
      <term><option>--interactive</></term>
81 82
      <listitem>
       <para>
P
Peter Eisentraut 已提交
83
       Issues a verification prompt before doing anything destructive.
84 85 86 87 88
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
P
Peter Eisentraut 已提交
89 90
      <term><option>-q</></term>
      <term><option>--quiet</></term>
91 92
      <listitem>
       <para>
P
Peter Eisentraut 已提交
93
        Do not display a response.
94 95 96
       </para>
      </listitem>
     </varlistentry>
P
Peter Eisentraut 已提交
97 98
    </variablelist>
  </para>
99

P
Peter Eisentraut 已提交
100 101 102 103 104
  <para>
   <application>createdb</application> also accepts the following
   command-line arguments for connection parameters:

   <variablelist>
105
     <varlistentry>
P
Peter Eisentraut 已提交
106 107
      <term><option>-h <replaceable class="parameter">host</replaceable></></term>
      <term><option>--host <replaceable class="parameter">host</replaceable></></term>
108 109
      <listitem>
       <para>
P
Peter Eisentraut 已提交
110 111 112 113
	Specifies the host name of the machine on which the 
	server
	is running.  If host begins with a slash, it is used 
	as the directory for the Unix domain socket.
114 115 116 117 118
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
P
Peter Eisentraut 已提交
119 120
      <term><option>-p <replaceable class="parameter">port</replaceable></></term>
      <term><option>--port <replaceable class="parameter">port</replaceable></></term>
121 122
      <listitem>
       <para>
P
Peter Eisentraut 已提交
123 124 125
	Specifies the Internet TCP/IP port or local Unix domain socket file 
	extension on which the server
	is listening for connections.
126 127 128 129 130
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
P
Peter Eisentraut 已提交
131 132
      <term><option>-U <replaceable class="parameter">username</replaceable></></term>
      <term><option>--username <replaceable class="parameter">username</replaceable></></term>
133 134
      <listitem>
       <para>
P
Peter Eisentraut 已提交
135
        User name to connect as
136 137 138 139 140
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
P
Peter Eisentraut 已提交
141 142
      <term><option>-W</></term>
      <term><option>--password</></term>
143 144
      <listitem>
       <para>
P
Peter Eisentraut 已提交
145
        Force password prompt.
146 147 148
       </para>
      </listitem>
     </varlistentry>
P
Peter Eisentraut 已提交
149 150
   </variablelist>
  </para>
151
 </refsect1>
152 153


154 155
 <refsect1>
   <title>Diagnostics</title>
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172

    <variablelist>
     <varlistentry>
      <term><computeroutput>DROP DATABASE</computeroutput></term>
      <listitem>
       <para>The database was successfully removed.</para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><computeroutput>dropdb: Database removal failed.</computeroutput></term>
      <listitem>
       <para>Something didn't work out.</para>
      </listitem>
     </varlistentry>
    </variablelist>

173
   <para>
174 175
    If there is an error condition, the backend error message will be displayed.
    See <xref linkend="SQL-DROPDATABASE" endterm="SQL-DROPDATABASE-title">
176
    for possibilities.
177
   </para>
178
 </refsect1>
179 180


181 182
 <refsect1>
  <title>Environment</title>
183

184 185 186 187 188 189 190 191 192 193 194 195 196
  <variablelist>
   <varlistentry>
    <term><envar>PGHOST</envar></term>
    <term><envar>PGPORT</envar></term>
    <term><envar>PGUSER</envar></term>

    <listitem>
     <para>
      Default connection parameters
     </para>
    </listitem>
   </varlistentry>
  </variablelist>
197 198
 </refsect1>

199

200
 <refsect1 id="R1-APP-DROPDB-2">
201
  <title>Examples</title>
202 203 204 205 206 207 208 209 210 211 212 213

   <para>
    To destroy the database <literal>demo</literal> on the default
    database server:
<screen>
<prompt>$ </prompt><userinput>dropdb demo</userinput>
<computeroutput>DROP DATABASE</computeroutput>
</screen>
   </para>

   <para>
    To destroy the database <literal>demo</literal> using the
P
Peter Eisentraut 已提交
214
    server on host <literal>eden</literal>, port 5000, with verification and a peek
215 216 217 218 219 220 221 222 223
    at the underlying query:
<screen>
<prompt>$ </prompt><userinput>dropdb -p 5000 -h eden -i -e demo</userinput>
<computeroutput>Database "demo" will be permanently deleted.
Are you sure? (y/n) </computeroutput><userinput>y</userinput>
<computeroutput>DROP DATABASE "demo"
DROP DATABASE</computeroutput>
</screen>
   </para>
224
 </refsect1>
225 226 227 228 229 230 231 232 233 234 235


 <refsect1>
  <title>See Also</title>

  <simplelist type="inline">
   <member><xref linkend="app-createdb"></member>
   <member><xref linkend="sql-dropdatabase" endterm="sql-dropdatabase-title"></member>
  </simplelist>
 </refsect1>

236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253
</refentry>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:nil
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
sgml-parent-document:nil
sgml-default-dtd-file:"../reference.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:"/usr/lib/sgml/catalog"
sgml-local-ecat-files:nil
End:
-->