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