]> granicus.if.org Git - postgresql/blob - doc/src/sgml/ref/alter_database.sgml
More minor updates and copy-editing.
[postgresql] / doc / src / sgml / ref / alter_database.sgml
1 <!--
2 $PostgreSQL: pgsql/doc/src/sgml/ref/alter_database.sgml,v 1.14 2005/01/04 00:39:53 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> SET <replaceable>parameter</replaceable> { TO | = } { <replaceable>value</replaceable> | DEFAULT }
24 ALTER DATABASE <replaceable class="PARAMETER">name</replaceable> RESET <replaceable>parameter</replaceable>
25
26 ALTER DATABASE <replaceable class="PARAMETER">name</replaceable> RENAME TO <replaceable>newname</replaceable>
27
28 ALTER DATABASE <replaceable class="PARAMETER">name</replaceable> OWNER TO <replaceable>newowner</replaceable>
29 </synopsis>
30  </refsynopsisdiv>
31
32  <refsect1>
33   <title>Description</title>
34
35   <para>
36    <command>ALTER DATABASE</command> changes the attributes
37    of a database.
38   </para>
39
40   <para>
41    The first two forms change the session default for a run-time
42    configuration variable for a <productname>PostgreSQL</productname>
43    database. Whenever a new session is subsequently started in that
44    database, the specified value becomes the session default value.
45    The database-specific default overrides whatever setting is present
46    in <filename>postgresql.conf</> or has been received from the
47    <command>postmaster</command> command line.  Only the database
48    owner or a superuser can change the session defaults for a
49    database.  Certain variables cannot be set this way, or can only be
50    set by a superuser.
51   </para>
52
53   <para>
54    The third form changes the name of the database.  Only the database
55    owner or a superuser can rename a database; non-superuser owners must
56    also have the
57    <literal>CREATEDB</literal> privilege.  The current database cannot
58    be renamed.  (Connect to a different database if you need to do
59    that.)
60   </para>
61
62   <para>
63    The fourth form changes the owner of the database.  Only a superuser
64    can change the database's owner.
65   </para>
66  </refsect1>
67
68  <refsect1>
69   <title>Parameters</title>
70
71     <variablelist>
72      <varlistentry>
73       <term><replaceable class="PARAMETER">name</replaceable></term>
74       <listitem>
75        <para>
76         The name of the database whose attributes are to be altered.
77        </para>
78       </listitem>
79      </varlistentry>
80
81      <varlistentry>
82       <term><replaceable>parameter</replaceable></term>
83       <term><replaceable>value</replaceable></term>
84       <listitem>
85        <para>
86         Set this database's session default for the specified configuration
87         parameter to the given value.  If
88         <replaceable>value</replaceable> is <literal>DEFAULT</literal>
89         or, equivalently, <literal>RESET</literal> is used, the
90         database-specific setting is removed, so the system-wide default
91         setting will be inherited in new sessions.  Use <literal>RESET
92         ALL</literal> to clear all database-specific settings.
93        </para>
94
95        <para>
96         See <xref linkend="sql-set" endterm="sql-set-title"> and <xref linkend="runtime-config">
97         for more information about allowed parameter names
98         and values.
99        </para>
100       </listitem>
101      </varlistentry>
102
103    <varlistentry>
104     <term><replaceable>newname</replaceable></term>
105     <listitem>
106      <para>
107       The new name of the database.
108      </para>
109     </listitem>
110    </varlistentry>
111
112    <varlistentry>
113     <term><replaceable class="parameter">newowner</replaceable></term>
114     <listitem>
115      <para>
116       The new owner of the database.
117      </para>
118     </listitem>
119    </varlistentry>
120   </variablelist>
121  </refsect1>
122
123  <refsect1>
124   <title>Notes</title>
125
126   <para>
127    It is also possible to tie a session default to a specific user
128    rather than to a database; see
129    <xref linkend="sql-alteruser" endterm="sql-alteruser-title">.
130    User-specific settings override database-specific
131    ones if there is a conflict.
132   </para>
133  </refsect1>
134
135  <refsect1>
136   <title>Examples</title>
137
138   <para>
139    To disable index scans by default in the database
140    <literal>test</literal>:
141
142 <programlisting>
143 ALTER DATABASE test SET enable_indexscan TO off;
144 </programlisting>
145   </para>
146  </refsect1>
147
148  <refsect1>
149   <title>Compatibility</title>
150     
151   <para>
152    The <command>ALTER DATABASE</command> statement is a
153    <productname>PostgreSQL</productname> extension.
154   </para>
155  </refsect1>
156
157  <refsect1>
158   <title>See Also</title>
159
160   <simplelist type="inline">
161    <member><xref linkend="sql-createdatabase" endterm="sql-createdatabase-title"></member>
162    <member><xref linkend="sql-dropdatabase" endterm="sql-dropdatabase-title"></member>
163    <member><xref linkend="sql-set" endterm="sql-set-title"></member>
164   </simplelist>
165  </refsect1>
166 </refentry>
167
168 <!-- Keep this comment at the end of the file
169 Local variables:
170 mode: sgml
171 sgml-omittag:nil
172 sgml-shorttag:t
173 sgml-minimize-attributes:nil
174 sgml-always-quote-attributes:t
175 sgml-indent-step:1
176 sgml-indent-data:t
177 sgml-parent-document:nil
178 sgml-default-dtd-file:"../reference.ced"
179 sgml-exposed-tags:nil
180 sgml-local-catalogs:"/usr/lib/sgml/catalog"
181 sgml-local-ecat-files:nil
182 End:
183 -->