File: sql-alterdatabase.html

package info (click to toggle)
pgadmin3 1.4.3-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 29,796 kB
  • ctags: 10,758
  • sloc: cpp: 55,356; sh: 6,164; ansic: 1,520; makefile: 576; sql: 482; xml: 100; perl: 18
file content (133 lines) | stat: -rw-r--r-- 6,487 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>ALTER DATABASE</title>
<link rel="stylesheet" href="stylesheet.css" type="text/css">
<link rev="made" href="pgsql-docs@postgresql.org">
<meta name="generator" content="DocBook XSL Stylesheets V1.70.0">
<link rel="start" href="index.html" title="PostgreSQL 8.1.4 Documentation">
<link rel="up" href="sql-commands.html" title="SQL Commands">
<link rel="prev" href="sql-alterconversion.html" title="ALTER CONVERSION">
<link rel="next" href="sql-alterdomain.html" title="ALTER DOMAIN">
<link rel="copyright" href="ln-legalnotice.html" title="Legal Notice">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry" lang="en">
<a name="sql-alterdatabase"></a><div class="titlepage"></div>
<div class="refnamediv">
<h2>Name</h2>
<p>ALTER DATABASE &#8212; change a database</p>
</div>
<a name="id741076"></a><div class="refsynopsisdiv">
<h2>Synopsis</h2>
<pre class="synopsis">ALTER DATABASE <em class="replaceable"><code>name</code></em> [ [ WITH ] <em class="replaceable"><code>option</code></em> [ ... ] ]

where <em class="replaceable"><code>option</code></em> can be:

    CONNECTION LIMIT <em class="replaceable"><code>connlimit</code></em>

ALTER DATABASE <em class="replaceable"><code>name</code></em> SET <em class="replaceable"><code>parameter</code></em> { TO | = } { <em class="replaceable"><code>value</code></em> | DEFAULT }
ALTER DATABASE <em class="replaceable"><code>name</code></em> RESET <em class="replaceable"><code>parameter</code></em>

ALTER DATABASE <em class="replaceable"><code>name</code></em> RENAME TO <em class="replaceable"><code>newname</code></em>

ALTER DATABASE <em class="replaceable"><code>name</code></em> OWNER TO <em class="replaceable"><code>new_owner</code></em></pre>
</div>
<div class="refsect1" lang="en">
<a name="id741169"></a><h2>Description</h2>
<p>   <code class="command">ALTER DATABASE</code> changes the attributes
   of a database.
  </p>
<p>   The first form changes certain per-database settings.  (See below for
   details.)  Only the database owner or a superuser can change these settings.
  </p>
<p>   The second and third forms change the session default for a run-time
   configuration variable for a <span class="productname">PostgreSQL</span>
   database. Whenever a new session is subsequently started in that
   database, the specified value becomes the session default value.
   The database-specific default overrides whatever setting is present
   in <code class="filename">postgresql.conf</code> or has been received from the
   <code class="command">postmaster</code> command line.  Only the database
   owner or a superuser can change the session defaults for a
   database.  Certain variables cannot be set this way, or can only be
   set by a superuser.
  </p>
<p>   The fourth form changes the name of the database.  Only the database
   owner or a superuser can rename a database; non-superuser owners must
   also have the
   <code class="literal">CREATEDB</code> privilege.  The current database cannot
   be renamed.  (Connect to a different database if you need to do
   that.)
  </p>
<p>   The fifth form changes the owner of the database.
   To alter the owner, you must own the database and also be a direct or
   indirect member of the new owning role, and you must have the
   <code class="literal">CREATEDB</code> privilege.
   (Note that superusers have all these privileges automatically.)
  </p>
</div>
<div class="refsect1" lang="en">
<a name="id741247"></a><h2>Parameters</h2>
<div class="variablelist"><dl>
<dt><span class="term"><em class="replaceable"><code>name</code></em></span></dt>
<dd><p>        The name of the database whose attributes are to be altered.
       </p></dd>
<dt><span class="term"><em class="replaceable"><code>connlimit</code></em></span></dt>
<dd><p>        How many concurrent connections can be made
        to this database.  -1 means no limit.
       </p></dd>
<dt>
<span xmlns="http://www.w3.org/TR/xhtml1/transitional" class="term"><em xmlns="" class="replaceable"><code>parameter</code></em></span><br xmlns="http://www.w3.org/TR/xhtml1/transitional"></br><span class="term"><em class="replaceable"><code>value</code></em></span>
</dt>
<dd>
<p>        Set this database's session default for the specified configuration
        parameter to the given value.  If
        <em class="replaceable"><code>value</code></em> is <code class="literal">DEFAULT</code>
        or, equivalently, <code class="literal">RESET</code> is used, the
        database-specific setting is removed, so the system-wide default
        setting will be inherited in new sessions.  Use <code class="literal">RESET
        ALL</code> to clear all database-specific settings.
       </p>
<p>        See <a href="sql-set.html">SET</a> and <a href="runtime-config.html" title="Chapter17.Server Configuration">Chapter17, <i>Server Configuration</i></a>
        for more information about allowed parameter names
        and values.
       </p>
</dd>
<dt><span class="term"><em class="replaceable"><code>newname</code></em></span></dt>
<dd><p>      The new name of the database.
     </p></dd>
<dt><span class="term"><em class="replaceable"><code>new_owner</code></em></span></dt>
<dd><p>      The new owner of the database.
     </p></dd>
</dl></div>
</div>
<div class="refsect1" lang="en">
<a name="id741363"></a><h2>Notes</h2>
<p>   It is also possible to tie a session default to a specific user
   rather than to a database; see
   <a href="sql-alteruser.html">ALTER USER</a>.
   User-specific settings override database-specific
   ones if there is a conflict.
  </p>
</div>
<div class="refsect1" lang="en">
<a name="id741384"></a><h2>Examples</h2>
<p>   To disable index scans by default in the database
   <code class="literal">test</code>:

</p>
<pre class="programlisting">ALTER DATABASE test SET enable_indexscan TO off;</pre>
<p>
  </p>
</div>
<div class="refsect1" lang="en">
<a name="id741405"></a><h2>Compatibility</h2>
<p>   The <code class="command">ALTER DATABASE</code> statement is a
   <span class="productname">PostgreSQL</span> extension.
  </p>
</div>
<div class="refsect1" lang="en">
<a name="id741425"></a><h2>See Also</h2>
<span class="simplelist"><a href="sql-createdatabase.html">CREATE DATABASE</a>, <a href="sql-dropdatabase.html">DROP DATABASE</a>, <a href="sql-set.html">SET</a></span>
</div>
</div></body>
</html>