Home Explore Blog CI



postgresql

1st chunk of `doc/src/sgml/ref/dropdb.sgml`
63526598acc7863f9f02640db665f66fd315319ba0d844820000000100000fa8
<!--
doc/src/sgml/ref/dropdb.sgml
PostgreSQL documentation
-->

<refentry id="app-dropdb">
 <indexterm zone="app-dropdb">
  <primary>dropdb</primary>
 </indexterm>

 <refmeta>
  <refentrytitle><application>dropdb</application></refentrytitle>
  <manvolnum>1</manvolnum>
  <refmiscinfo>Application</refmiscinfo>
 </refmeta>

 <refnamediv>
  <refname>dropdb</refname>
  <refpurpose>remove a <productname>PostgreSQL</productname> database</refpurpose>
 </refnamediv>

 <refsynopsisdiv>
  <cmdsynopsis>
   <command>dropdb</command>
   <arg rep="repeat"><replaceable>connection-option</replaceable></arg>
   <arg rep="repeat"><replaceable>option</replaceable></arg>
   <arg choice="plain"><replaceable>dbname</replaceable></arg>
  </cmdsynopsis>
 </refsynopsisdiv>


 <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>
   <application>dropdb</application> is a wrapper around the
   <acronym>SQL</acronym> command <link linkend="sql-dropdatabase"><command>DROP DATABASE</command></link>.
   There is no effective difference between dropping databases via
   this utility and via other methods for accessing the server.
  </para>

 </refsect1>


 <refsect1>
  <title>Options</title>

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

    <variablelist>
     <varlistentry>
      <term><replaceable class="parameter">dbname</replaceable></term>
      <listitem>
       <para>
        Specifies the name of the database to be removed.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><option>-e</option></term>
      <term><option>--echo</option></term>
      <listitem>
       <para>
        Echo the commands that <application>dropdb</application> generates
        and sends to the server.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><option>-f</option></term>
      <term><option>--force</option></term>
      <listitem>
       <para>
        Attempt to terminate all existing connections to the target database
        before dropping it.   See <xref linkend="sql-dropdatabase"/> for more
        information on this option.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><option>-i</option></term>
      <term><option>--interactive</option></term>
      <listitem>
       <para>
       Issues a verification prompt before doing anything destructive.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
       <term><option>-V</option></term>
       <term><option>--version</option></term>
       <listitem>
       <para>
       Print the <application>dropdb</application> version and exit.
       </para>
       </listitem>
     </varlistentry>

     <varlistentry>
      <term><option>--if-exists</option></term>
      <listitem>
       <para>
       Do not throw an error if the database does not exist. A notice is issued
       in this case.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
       <term><option>-?</option></term>
       <term><option>--help</option></term>
       <listitem>
       <para>
       Show help about <application>dropdb</application> command line
       arguments, and exit.
       </para>
       </listitem>
     </varlistentry>

    </variablelist>

  </para>

  <para>
   <application>dropdb</application> also accepts the following
   command-line arguments for connection parameters:

   <variablelist>
     <varlistentry>
      <term><option>-h <replaceable class="parameter">host</replaceable></option></term>
      <term><option>--host=<replaceable class="parameter">host</replaceable></option></term>
      <listitem>
       <para>
        Specifies the host name of the machine on which the
        server
        is running.

Title: dropdb: Remove a PostgreSQL Database
Summary
The `dropdb` command removes a PostgreSQL database. The user must be a database superuser or the owner of the database. It's a wrapper around the SQL command `DROP DATABASE`. Options include specifying the database name, echoing commands, forcing termination of connections, prompting for verification, showing the version, ignoring errors if the database doesn't exist, and displaying help. Connection parameters such as host can also be specified.