]> granicus.if.org Git - postgresql/blob - doc/src/sgml/ref/alter_database.sgml
Update documentation to reflect the new ALTER OWNER rules for all
[postgresql] / doc / src / sgml / ref / alter_database.sgml
1 <!--
2 $PostgreSQL: pgsql/doc/src/sgml/ref/alter_database.sgml,v 1.17 2005/10/13 22:44:51 tgl Exp $
3 PostgreSQL documentation
4 -->
5
6 <refentry id="SQL-ALTERDATABASE">
7  <refmeta>
8   <refentrytitle id="sql-alterdatabase-title">ALTER DATABASE</refentrytitle>
9   <refmiscinfo>SQL - Language Statements</refmiscinfo>
10  </refmeta>
11
12  <refnamediv>
13   <refname>ALTER DATABASE</refname>
14   <refpurpose>change a database</refpurpose>
15  </refnamediv>
16
17  <indexterm zone="sql-alterdatabase">
18   <primary>ALTER DATABASE</primary>
19  </indexterm>
20
21  <refsynopsisdiv>
22 <synopsis>
23 ALTER DATABASE <replaceable class="PARAMETER">name</replaceable> [ [ WITH ] <replaceable class="PARAMETER">option</replaceable> [ ... ] ]
24
25 where <replaceable class="PARAMETER">option</replaceable> can be:
26
27     CONNECTION LIMIT <replaceable class="PARAMETER">connlimit</replaceable>
28
29 ALTER DATABASE <replaceable class="PARAMETER">name</replaceable> SET <replaceable>parameter</replaceable> { TO | = } { <replaceable>value</replaceable> | DEFAULT }
30 ALTER DATABASE <replaceable class="PARAMETER">name</replaceable> RESET <replaceable>parameter</replaceable>
31
32 ALTER DATABASE <replaceable class="PARAMETER">name</replaceable> RENAME TO <replaceable>newname</replaceable>
33
34 ALTER DATABASE <replaceable class="PARAMETER">name</replaceable> OWNER TO <replaceable>new_owner</replaceable>
35 </synopsis>
36  </refsynopsisdiv>
37
38  <refsect1>
39   <title>Description</title>
40
41   <para>
42    <command>ALTER DATABASE</command> changes the attributes
43    of a database.
44   </para>
45
46   <para>
47    The first form changes certain per-database settings.  (See below for
48    details.)  Only the database owner or a superuser can change these settings.
49   </para> 
50
51   <para>
52    The second and third forms change the session default for a run-time
53    configuration variable for a <productname>PostgreSQL</productname>
54    database. Whenever a new session is subsequently started in that
55    database, the specified value becomes the session default value.
56    The database-specific default overrides whatever setting is present
57    in <filename>postgresql.conf</> or has been received from the
58    <command>postmaster</command> command line.  Only the database
59    owner or a superuser can change the session defaults for a
60    database.  Certain variables cannot be set this way, or can only be
61    set by a superuser.
62   </para>
63
64   <para>
65    The fourth form changes the name of the database.  Only the database
66    owner or a superuser can rename a database; non-superuser owners must
67    also have the
68    <literal>CREATEDB</literal> privilege.  The current database cannot
69    be renamed.  (Connect to a different database if you need to do
70    that.)
71   </para>
72
73   <para>
74    The fifth form changes the owner of the database.
75    To alter the owner, you must own the database and also be a direct or
76    indirect member of the new owning role, and you must have the
77    <literal>CREATEDB</literal> privilege.
78    (Note that superusers have all these privileges automatically.)
79   </para>
80  </refsect1>
81
82  <refsect1>
83   <title>Parameters</title>
84
85     <variablelist>
86      <varlistentry>
87       <term><replaceable class="PARAMETER">name</replaceable></term>
88       <listitem>
89        <para>
90         The name of the database whose attributes are to be altered.
91        </para>
92       </listitem>
93      </varlistentry>
94
95      <varlistentry>
96       <term><replaceable class="parameter">connlimit</replaceable></term>
97       <listitem>
98        <para>
99         How many concurrent connections can be made
100         to this database.  -1 means no limit.
101        </para>
102       </listitem>
103      </varlistentry> 
104
105      <varlistentry>
106       <term><replaceable>parameter</replaceable></term>
107       <term><replaceable>value</replaceable></term>
108       <listitem>
109        <para>
110         Set this database's session default for the specified configuration
111         parameter to the given value.  If
112         <replaceable>value</replaceable> is <literal>DEFAULT</literal>
113         or, equivalently, <literal>RESET</literal> is used, the
114         database-specific setting is removed, so the system-wide default
115         setting will be inherited in new sessions.  Use <literal>RESET
116         ALL</literal> to clear all database-specific settings.
117        </para>
118
119        <para>
120         See <xref linkend="sql-set" endterm="sql-set-title"> and <xref linkend="runtime-config">
121         for more information about allowed parameter names
122         and values.
123        </para>
124       </listitem>
125      </varlistentry>
126
127    <varlistentry>
128     <term><replaceable>newname</replaceable></term>
129     <listitem>
130      <para>
131       The new name of the database.
132      </para>
133     </listitem>
134    </varlistentry>
135
136    <varlistentry>
137     <term><replaceable class="parameter">new_owner</replaceable></term>
138     <listitem>
139      <para>
140       The new owner of the database.
141      </para>
142     </listitem>
143    </varlistentry>
144   </variablelist>
145  </refsect1>
146
147  <refsect1>
148   <title>Notes</title>
149
150   <para>
151    It is also possible to tie a session default to a specific user
152    rather than to a database; see
153    <xref linkend="sql-alteruser" endterm="sql-alteruser-title">.
154    User-specific settings override database-specific
155    ones if there is a conflict.
156   </para>
157  </refsect1>
158
159  <refsect1>
160   <title>Examples</title>
161
162   <para>
163    To disable index scans by default in the database
164    <literal>test</literal>:
165
166 <programlisting>
167 ALTER DATABASE test SET enable_indexscan TO off;
168 </programlisting>
169   </para>
170  </refsect1>
171
172  <refsect1>
173   <title>Compatibility</title>
174     
175   <para>
176    The <command>ALTER DATABASE</command> statement is a
177    <productname>PostgreSQL</productname> extension.
178   </para>
179  </refsect1>
180
181  <refsect1>
182   <title>See Also</title>
183
184   <simplelist type="inline">
185    <member><xref linkend="sql-createdatabase" endterm="sql-createdatabase-title"></member>
186    <member><xref linkend="sql-dropdatabase" endterm="sql-dropdatabase-title"></member>
187    <member><xref linkend="sql-set" endterm="sql-set-title"></member>
188   </simplelist>
189  </refsect1>
190 </refentry>
191
192 <!-- Keep this comment at the end of the file
193 Local variables:
194 mode: sgml
195 sgml-omittag:nil
196 sgml-shorttag:t
197 sgml-minimize-attributes:nil
198 sgml-always-quote-attributes:t
199 sgml-indent-step:1
200 sgml-indent-data:t
201 sgml-parent-document:nil
202 sgml-default-dtd-file:"../reference.ced"
203 sgml-exposed-tags:nil
204 sgml-local-catalogs:"/usr/lib/sgml/catalog"
205 sgml-local-ecat-files:nil
206 End:
207 -->