gooderp18绿色标准版
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

108 行
9.8KB

  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>ALTER DATABASE</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="sql-alterconversion.html" title="ALTER CONVERSION" /><link rel="next" href="sql-alterdefaultprivileges.html" title="ALTER DEFAULT PRIVILEGES" /></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">ALTER DATABASE</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="sql-alterconversion.html" title="ALTER CONVERSION">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="sql-commands.html" title="SQL Commands">Up</a></td><th width="60%" align="center">SQL Commands</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="sql-alterdefaultprivileges.html" title="ALTER DEFAULT PRIVILEGES">Next</a></td></tr></table><hr></hr></div><div class="refentry" id="SQL-ALTERDATABASE"><div class="titlepage"></div><a id="id-1.9.3.7.1" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle">ALTER DATABASE</span></h2><p>ALTER DATABASE — change a database</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="synopsis">
  3. ALTER DATABASE <em class="replaceable"><code>name</code></em> [ [ WITH ] <em class="replaceable"><code>option</code></em> [ ... ] ]
  4. <span class="phrase">where <em class="replaceable"><code>option</code></em> can be:</span>
  5. ALLOW_CONNECTIONS <em class="replaceable"><code>allowconn</code></em>
  6. CONNECTION LIMIT <em class="replaceable"><code>connlimit</code></em>
  7. IS_TEMPLATE <em class="replaceable"><code>istemplate</code></em>
  8. ALTER DATABASE <em class="replaceable"><code>name</code></em> RENAME TO <em class="replaceable"><code>new_name</code></em>
  9. ALTER DATABASE <em class="replaceable"><code>name</code></em> OWNER TO { <em class="replaceable"><code>new_owner</code></em> | CURRENT_USER | SESSION_USER }
  10. ALTER DATABASE <em class="replaceable"><code>name</code></em> SET TABLESPACE <em class="replaceable"><code>new_tablespace</code></em>
  11. ALTER DATABASE <em class="replaceable"><code>name</code></em> SET <em class="replaceable"><code>configuration_parameter</code></em> { TO | = } { <em class="replaceable"><code>value</code></em> | DEFAULT }
  12. ALTER DATABASE <em class="replaceable"><code>name</code></em> SET <em class="replaceable"><code>configuration_parameter</code></em> FROM CURRENT
  13. ALTER DATABASE <em class="replaceable"><code>name</code></em> RESET <em class="replaceable"><code>configuration_parameter</code></em>
  14. ALTER DATABASE <em class="replaceable"><code>name</code></em> RESET ALL
  15. </pre></div><div class="refsect1" id="id-1.9.3.7.5"><h2>Description</h2><p>
  16. <code class="command">ALTER DATABASE</code> changes the attributes
  17. of a database.
  18. </p><p>
  19. The first form changes certain per-database settings. (See below for
  20. details.) Only the database owner or a superuser can change these settings.
  21. </p><p>
  22. The second form changes the name of the database. Only the database
  23. owner or a superuser can rename a database; non-superuser owners must
  24. also have the
  25. <code class="literal">CREATEDB</code> privilege. The current database cannot
  26. be renamed. (Connect to a different database if you need to do
  27. that.)
  28. </p><p>
  29. The third form changes the owner of the database.
  30. To alter the owner, you must own the database and also be a direct or
  31. indirect member of the new owning role, and you must have the
  32. <code class="literal">CREATEDB</code> privilege.
  33. (Note that superusers have all these privileges automatically.)
  34. </p><p>
  35. The fourth form changes the default tablespace of the database.
  36. Only the database owner or a superuser can do this; you must also have
  37. create privilege for the new tablespace.
  38. This command physically moves any tables or indexes in the database's old
  39. default tablespace to the new tablespace. The new default tablespace
  40. must be empty for this database, and no one can be connected to
  41. the database. Tables and indexes in non-default tablespaces are
  42. unaffected.
  43. </p><p>
  44. The remaining forms change the session default for a run-time
  45. configuration variable for a <span class="productname">PostgreSQL</span>
  46. database. Whenever a new session is subsequently started in that
  47. database, the specified value becomes the session default value.
  48. The database-specific default overrides whatever setting is present
  49. in <code class="filename">postgresql.conf</code> or has been received from the
  50. <code class="command">postgres</code> command line. Only the database
  51. owner or a superuser can change the session defaults for a
  52. database. Certain variables cannot be set this way, or can only be
  53. set by a superuser.
  54. </p></div><div class="refsect1" id="id-1.9.3.7.6"><h2>Parameters</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><em class="replaceable"><code>name</code></em></span></dt><dd><p>
  55. The name of the database whose attributes are to be altered.
  56. </p></dd><dt><span class="term"><em class="replaceable"><code>allowconn</code></em></span></dt><dd><p>
  57. If false then no one can connect to this database.
  58. </p></dd><dt><span class="term"><em class="replaceable"><code>connlimit</code></em></span></dt><dd><p>
  59. How many concurrent connections can be made
  60. to this database. -1 means no limit.
  61. </p></dd><dt><span class="term"><em class="replaceable"><code>istemplate</code></em></span></dt><dd><p>
  62. If true, then this database can be cloned by any user with <code class="literal">CREATEDB</code>
  63. privileges; if false, then only superusers or the owner of the
  64. database can clone it.
  65. </p></dd><dt><span class="term"><em class="replaceable"><code>new_name</code></em></span></dt><dd><p>
  66. The new name of the database.
  67. </p></dd><dt><span class="term"><em class="replaceable"><code>new_owner</code></em></span></dt><dd><p>
  68. The new owner of the database.
  69. </p></dd><dt><span class="term"><em class="replaceable"><code>new_tablespace</code></em></span></dt><dd><p>
  70. The new default tablespace of the database.
  71. </p><p>
  72. This form of the command cannot be executed inside a transaction block.
  73. </p></dd><dt><span class="term"><em class="replaceable"><code>configuration_parameter</code></em><br /></span><span class="term"><em class="replaceable"><code>value</code></em></span></dt><dd><p>
  74. Set this database's session default for the specified configuration
  75. parameter to the given value. If
  76. <em class="replaceable"><code>value</code></em> is <code class="literal">DEFAULT</code>
  77. or, equivalently, <code class="literal">RESET</code> is used, the
  78. database-specific setting is removed, so the system-wide default
  79. setting will be inherited in new sessions. Use <code class="literal">RESET
  80. ALL</code> to clear all database-specific settings.
  81. <code class="literal">SET FROM CURRENT</code> saves the session's current value of
  82. the parameter as the database-specific value.
  83. </p><p>
  84. See <a class="xref" href="sql-set.html" title="SET"><span class="refentrytitle">SET</span></a> and <a class="xref" href="runtime-config.html" title="Chapter 19. Server Configuration">Chapter 19</a>
  85. for more information about allowed parameter names
  86. and values.
  87. </p></dd></dl></div></div><div class="refsect1" id="id-1.9.3.7.7"><h2>Notes</h2><p>
  88. It is also possible to tie a session default to a specific role
  89. rather than to a database; see
  90. <a class="xref" href="sql-alterrole.html" title="ALTER ROLE"><span class="refentrytitle">ALTER ROLE</span></a>.
  91. Role-specific settings override database-specific
  92. ones if there is a conflict.
  93. </p></div><div class="refsect1" id="id-1.9.3.7.8"><h2>Examples</h2><p>
  94. To disable index scans by default in the database
  95. <code class="literal">test</code>:
  96. </p><pre class="programlisting">
  97. ALTER DATABASE test SET enable_indexscan TO off;
  98. </pre></div><div class="refsect1" id="id-1.9.3.7.9"><h2>Compatibility</h2><p>
  99. The <code class="command">ALTER DATABASE</code> statement is a
  100. <span class="productname">PostgreSQL</span> extension.
  101. </p></div><div class="refsect1" id="id-1.9.3.7.10"><h2>See Also</h2><span class="simplelist"><a class="xref" href="sql-createdatabase.html" title="CREATE DATABASE"><span class="refentrytitle">CREATE DATABASE</span></a>, <a class="xref" href="sql-dropdatabase.html" title="DROP DATABASE"><span class="refentrytitle">DROP DATABASE</span></a>, <a class="xref" href="sql-set.html" title="SET"><span class="refentrytitle">SET</span></a>, <a class="xref" href="sql-createtablespace.html" title="CREATE TABLESPACE"><span class="refentrytitle">CREATE TABLESPACE</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="sql-alterconversion.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="sql-commands.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="sql-alterdefaultprivileges.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">ALTER CONVERSION </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> ALTER DEFAULT PRIVILEGES</td></tr></table></div></body></html>
上海开阖软件有限公司 沪ICP备12045867号-1