codekingpro/portable-devtools
115k
1<?xml version="1.0" encoding="UTF-8" standalone="no"?>2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>dropdb</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="app-createuser.html" title="createuser" /><link rel="next" href="app-dropuser.html" title="dropuser" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center"><span class="application">dropdb</span></th></tr><tr><td width="10%" align="left"><a accesskey="p" href="app-createuser.html" title="createuser">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="reference-client.html" title="PostgreSQL Client Applications">Up</a></td><th width="60%" align="center">PostgreSQL Client Applications</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="app-dropuser.html" title="dropuser">Next</a></td></tr></table><hr /></div><div class="refentry" id="APP-DROPDB"><div class="titlepage"></div><a id="id-1.9.4.6.1" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle"><span class="application">dropdb</span></span></h2><p>dropdb — remove a <span class="productname">PostgreSQL</span> database</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p id="id-1.9.4.6.4.1"><code class="command">dropdb</code> [<em class="replaceable"><code>connection-option</code></em>...] [<em class="replaceable"><code>option</code></em>...] <em class="replaceable"><code>dbname</code></em> </p></div></div><div class="refsect1" id="id-1.9.4.6.5"><h2>Description</h2><p>3 <span class="application">dropdb</span> destroys an existing4 <span class="productname">PostgreSQL</span> database.5 The user who executes this command must be a database6 superuser or the owner of the database.7 </p><p>8 <span class="application">dropdb</span> is a wrapper around the9 <acronym class="acronym">SQL</acronym> command <a class="link" href="sql-dropdatabase.html" title="DROP DATABASE"><code class="command">DROP DATABASE</code></a>.10 There is no effective difference between dropping databases via11 this utility and via other methods for accessing the server.12 </p></div><div class="refsect1" id="id-1.9.4.6.6"><h2>Options</h2><p>13 <span class="application">dropdb</span> accepts the following command-line arguments:14 15 </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><em class="replaceable"><code>dbname</code></em></span></dt><dd><p>16 Specifies the name of the database to be removed.17 </p></dd><dt><span class="term"><code class="option">-e</code><br /></span><span class="term"><code class="option">--echo</code></span></dt><dd><p>18 Echo the commands that <span class="application">dropdb</span> generates19 and sends to the server.20 </p></dd><dt><span class="term"><code class="option">-f</code><br /></span><span class="term"><code class="option">--force</code></span></dt><dd><p>21 Attempt to terminate all existing connections to the target database22 before dropping it. See <a class="xref" href="sql-dropdatabase.html" title="DROP DATABASE"><span class="refentrytitle">DROP DATABASE</span></a> for more23 information on this option.24 </p></dd><dt><span class="term"><code class="option">-i</code><br /></span><span class="term"><code class="option">--interactive</code></span></dt><dd><p>25 Issues a verification prompt before doing anything destructive.26 </p></dd><dt><span class="term"><code class="option">-V</code><br /></span><span class="term"><code class="option">--version</code></span></dt><dd><p>27 Print the <span class="application">dropdb</span> version and exit.28 </p></dd><dt><span class="term"><code class="option">--if-exists</code></span></dt><dd><p>29 Do not throw an error if the database does not exist. A notice is issued30 in this case.31 </p></dd><dt><span class="term"><code class="option">-?</code><br /></span><span class="term"><code class="option">--help</code></span></dt><dd><p>32 Show help about <span class="application">dropdb</span> command line33 arguments, and exit.34 </p></dd></dl></div><p>35 36 </p><p>37 <span class="application">dropdb</span> also accepts the following38 command-line arguments for connection parameters:39 40 </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">-h <em class="replaceable"><code>host</code></em></code><br /></span><span class="term"><code class="option">--host=<em class="replaceable"><code>host</code></em></code></span></dt><dd><p>41 Specifies the host name of the machine on which the42 server43 is running. If the value begins with a slash, it is used44 as the directory for the Unix domain socket.45 </p></dd><dt><span class="term"><code class="option">-p <em class="replaceable"><code>port</code></em></code><br /></span><span class="term"><code class="option">--port=<em class="replaceable"><code>port</code></em></code></span></dt><dd><p>46 Specifies the TCP port or local Unix domain socket file47 extension on which the server48 is listening for connections.49 </p></dd><dt><span class="term"><code class="option">-U <em class="replaceable"><code>username</code></em></code><br /></span><span class="term"><code class="option">--username=<em class="replaceable"><code>username</code></em></code></span></dt><dd><p>50 User name to connect as.51 </p></dd><dt><span class="term"><code class="option">-w</code><br /></span><span class="term"><code class="option">--no-password</code></span></dt><dd><p>52 Never issue a password prompt. If the server requires53 password authentication and a password is not available by54 other means such as a <code class="filename">.pgpass</code> file, the55 connection attempt will fail. This option can be useful in56 batch jobs and scripts where no user is present to enter a57 password.58 </p></dd><dt><span class="term"><code class="option">-W</code><br /></span><span class="term"><code class="option">--password</code></span></dt><dd><p>59 Force <span class="application">dropdb</span> to prompt for a60 password before connecting to a database.61 </p><p>62 This option is never essential, since63 <span class="application">dropdb</span> will automatically prompt64 for a password if the server demands password authentication.65 However, <span class="application">dropdb</span> will waste a66 connection attempt finding out that the server wants a password.67 In some cases it is worth typing <code class="option">-W</code> to avoid the extra68 connection attempt.69 </p></dd><dt><span class="term"><code class="option">--maintenance-db=<em class="replaceable"><code>dbname</code></em></code></span></dt><dd><p>70 Specifies the name of the database to connect to in order to drop the71 target database. If not specified, the <code class="literal">postgres</code>72 database will be used; if that does not exist (or is the database73 being dropped), <code class="literal">template1</code> will be used.74 This can be a <a class="link" href="libpq-connect.html#LIBPQ-CONNSTRING" title="34.1.1. Connection Strings">connection75 string</a>. If so, connection string parameters will override any76 conflicting command line options.77 </p></dd></dl></div><p>78 </p></div><div class="refsect1" id="id-1.9.4.6.7"><h2>Environment</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="envar">PGHOST</code><br /></span><span class="term"><code class="envar">PGPORT</code><br /></span><span class="term"><code class="envar">PGUSER</code></span></dt><dd><p>79 Default connection parameters80 </p></dd><dt><span class="term"><code class="envar">PG_COLOR</code></span></dt><dd><p>81 Specifies whether to use color in diagnostic messages. Possible values82 are <code class="literal">always</code>, <code class="literal">auto</code> and83 <code class="literal">never</code>.84 </p></dd></dl></div><p>85 This utility, like most other <span class="productname">PostgreSQL</span> utilities,86 also uses the environment variables supported by <span class="application">libpq</span>87 (see <a class="xref" href="libpq-envars.html" title="34.15. Environment Variables">Section 34.15</a>).88 </p></div><div class="refsect1" id="id-1.9.4.6.8"><h2>Diagnostics</h2><p>89 In case of difficulty, see <a class="xref" href="sql-dropdatabase.html" title="DROP DATABASE"><span class="refentrytitle">DROP DATABASE</span></a>90 and <a class="xref" href="app-psql.html" title="psql"><span class="refentrytitle"><span class="application">psql</span></span></a> for91 discussions of potential problems and error messages.92 The database server must be running at the93 targeted host. Also, any default connection settings and environment94 variables used by the <span class="application">libpq</span> front-end95 library will apply.96 </p></div><div class="refsect1" id="id-1.9.4.6.9"><h2>Examples</h2><p>97 To destroy the database <code class="literal">demo</code> on the default98 database server:99</p><pre class="screen">100<code class="prompt">$ </code><strong class="userinput"><code>dropdb demo</code></strong>101</pre><p>102 </p><p>103 To destroy the database <code class="literal">demo</code> using the104 server on host <code class="literal">eden</code>, port 5000, with verification and a peek105 at the underlying command:106</p><pre class="screen">107<code class="prompt">$ </code><strong class="userinput"><code>dropdb -p 5000 -h eden -i -e demo</code></strong>108<code class="computeroutput">Database "demo" will be permanently deleted.109Are you sure? (y/n) </code><strong class="userinput"><code>y</code></strong>110<code class="computeroutput">DROP DATABASE demo;</code>111</pre></div><div class="refsect1" id="id-1.9.4.6.10"><h2>See Also</h2><span class="simplelist"><a class="xref" href="app-createdb.html" title="createdb"><span class="refentrytitle"><span class="application">createdb</span></span></a>, <a class="xref" href="sql-dropdatabase.html" title="DROP DATABASE"><span class="refentrytitle">DROP DATABASE</span></a></span></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="app-createuser.html" title="createuser">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="reference-client.html" title="PostgreSQL Client Applications">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="app-dropuser.html" title="dropuser">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="application">createuser</span> </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> <span class="application">dropuser</span></td></tr></table></div></body></html>