gooderp18绿色标准版
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

104 lines
11KB

  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 V1.79.1" /><link rel="prev" href="app-createuser.html" title="createuser" /><link rel="next" href="app-dropuser.html" title="dropuser" /></head><body><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center"><span xmlns="http://www.w3.org/1999/xhtml" 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 12.4 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="app-dropuser.html" title="dropuser">Next</a></td></tr></table><hr></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 existing
  4. <span class="productname">PostgreSQL</span> database.
  5. The user who executes this command must be a database
  6. superuser or the owner of the database.
  7. </p><p>
  8. <span class="application">dropdb</span> is a wrapper around the
  9. <acronym class="acronym">SQL</acronym> command <a class="xref" href="sql-dropdatabase.html" title="DROP DATABASE"><span class="refentrytitle">DROP DATABASE</span></a>.
  10. There is no effective difference between dropping databases via
  11. 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. </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><em class="replaceable"><code>dbname</code></em></span></dt><dd><p>
  15. Specifies the name of the database to be removed.
  16. </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>
  17. Echo the commands that <span class="application">dropdb</span> generates
  18. and sends to the server.
  19. </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>
  20. Issues a verification prompt before doing anything destructive.
  21. </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>
  22. Print the <span class="application">dropdb</span> version and exit.
  23. </p></dd><dt><span class="term"><code class="option">--if-exists</code></span></dt><dd><p>
  24. Do not throw an error if the database does not exist. A notice is issued
  25. in this case.
  26. </p></dd><dt><span class="term"><code class="option">-?</code><br /></span><span class="term"><code class="option">--help</code></span></dt><dd><p>
  27. Show help about <span class="application">dropdb</span> command line
  28. arguments, and exit.
  29. </p></dd></dl></div><p>
  30. </p><p>
  31. <span class="application">dropdb</span> also accepts the following
  32. command-line arguments for connection parameters:
  33. </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>
  34. Specifies the host name of the machine on which the
  35. server
  36. is running. If the value begins with a slash, it is used
  37. as the directory for the Unix domain socket.
  38. </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>
  39. Specifies the TCP port or local Unix domain socket file
  40. extension on which the server
  41. is listening for connections.
  42. </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>
  43. User name to connect as.
  44. </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>
  45. Never issue a password prompt. If the server requires
  46. password authentication and a password is not available by
  47. other means such as a <code class="filename">.pgpass</code> file, the
  48. connection attempt will fail. This option can be useful in
  49. batch jobs and scripts where no user is present to enter a
  50. password.
  51. </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>
  52. Force <span class="application">dropdb</span> to prompt for a
  53. password before connecting to a database.
  54. </p><p>
  55. This option is never essential, since
  56. <span class="application">dropdb</span> will automatically prompt
  57. for a password if the server demands password authentication.
  58. However, <span class="application">dropdb</span> will waste a
  59. connection attempt finding out that the server wants a password.
  60. In some cases it is worth typing <code class="option">-W</code> to avoid the extra
  61. connection attempt.
  62. </p></dd><dt><span class="term"><code class="option">--maintenance-db=<em class="replaceable"><code>dbname</code></em></code></span></dt><dd><p>
  63. Specifies the name of the database to connect to in order to drop the
  64. target database. If not specified, the <code class="literal">postgres</code>
  65. database will be used; if that does not exist (or is the database
  66. being dropped), <code class="literal">template1</code> will be used.
  67. </p></dd></dl></div><p>
  68. </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>
  69. Default connection parameters
  70. </p></dd><dt><span class="term"><code class="envar">PG_COLOR</code></span></dt><dd><p>
  71. Specifies whether to use color in diagnostic messages. Possible values
  72. are <code class="literal">always</code>, <code class="literal">auto</code> and
  73. <code class="literal">never</code>.
  74. </p></dd></dl></div><p>
  75. This utility, like most other <span class="productname">PostgreSQL</span> utilities,
  76. also uses the environment variables supported by <span class="application">libpq</span>
  77. (see <a class="xref" href="libpq-envars.html" title="33.14. Environment Variables">Section 33.14</a>).
  78. </p></div><div class="refsect1" id="id-1.9.4.6.8"><h2>Diagnostics</h2><p>
  79. In case of difficulty, see <a class="xref" href="sql-dropdatabase.html" title="DROP DATABASE"><span class="refentrytitle">DROP DATABASE</span></a>
  80. and <a class="xref" href="app-psql.html" title="psql"><span class="refentrytitle"><span class="application">psql</span></span></a> for
  81. discussions of potential problems and error messages.
  82. The database server must be running at the
  83. targeted host. Also, any default connection settings and environment
  84. variables used by the <span class="application">libpq</span> front-end
  85. library will apply.
  86. </p></div><div class="refsect1" id="id-1.9.4.6.9"><h2>Examples</h2><p>
  87. To destroy the database <code class="literal">demo</code> on the default
  88. database server:
  89. </p><pre class="screen">
  90. <code class="prompt">$ </code><strong class="userinput"><code>dropdb demo</code></strong>
  91. </pre><p>
  92. </p><p>
  93. To destroy the database <code class="literal">demo</code> using the
  94. server on host <code class="literal">eden</code>, port 5000, with verification and a peek
  95. at the underlying command:
  96. </p><pre class="screen">
  97. <code class="prompt">$ </code><strong class="userinput"><code>dropdb -p 5000 -h eden -i -e demo</code></strong>
  98. <code class="computeroutput">Database "demo" will be permanently deleted.
  99. Are you sure? (y/n) </code><strong class="userinput"><code>y</code></strong>
  100. <code class="computeroutput">DROP DATABASE demo;</code>
  101. </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">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="reference-client.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="app-dropuser.html">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">Home</a></td><td width="40%" align="right" valign="top"> <span class="application">dropuser</span></td></tr></table></div></body></html>
上海开阖软件有限公司 沪ICP备12045867号-1