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