]> granicus.if.org Git - postgresql/blob - doc/src/sgml/ref/alter_index.sgml
c212fd09f93f59b214522f1ef9de2f573dc834d0
[postgresql] / doc / src / sgml / ref / alter_index.sgml
1 <!--
2 $PostgreSQL: pgsql/doc/src/sgml/ref/alter_index.sgml,v 1.6 2005/08/22 19:39:52 tgl Exp $
3 PostgreSQL documentation
4 -->
5
6 <refentry id="SQL-ALTERINDEX">
7  <refmeta>
8   <refentrytitle id="sql-alterindex-title">ALTER INDEX</refentrytitle>
9   <refmiscinfo>SQL - Language Statements</refmiscinfo>
10  </refmeta>
11
12  <refnamediv>
13   <refname>ALTER INDEX</refname>
14   <refpurpose>change the definition of an index</refpurpose>
15  </refnamediv>
16
17  <indexterm zone="sql-alterindex">
18   <primary>ALTER INDEX</primary>
19  </indexterm>
20
21  <refsynopsisdiv>
22 <synopsis>
23 ALTER INDEX <replaceable class="PARAMETER">name</replaceable> RENAME TO <replaceable class="PARAMETER">new_name</replaceable>
24 ALTER INDEX <replaceable class="PARAMETER">name</replaceable> SET TABLESPACE <replaceable class="PARAMETER">tablespace_name</replaceable>
25 </synopsis>
26  </refsynopsisdiv>
27
28  <refsect1>
29   <title>Description</title>
30
31   <para>
32    <command>ALTER INDEX</command> changes the definition of an existing index.
33    There are several subforms:
34
35   <variablelist>
36
37    <varlistentry>
38     <term><literal>RENAME</literal></term>
39     <listitem>
40      <para>
41       The <literal>RENAME</literal> form changes the name of the index. 
42       There is no effect on the stored data.
43      </para>
44     </listitem>
45    </varlistentry>
46
47    <varlistentry>
48     <term><literal>SET TABLESPACE</literal></term>
49     <listitem>
50      <para>
51       This form changes the index's tablespace to the specified tablespace and
52       moves the data file(s) associated with the index to the new tablespace.
53       See also 
54       <xref linkend="SQL-CREATETABLESPACE" endterm="sql-createtablespace-title">.
55      </para>
56     </listitem>
57    </varlistentry>
58
59   </variablelist>
60   </para>
61
62  </refsect1>
63
64  <refsect1>
65   <title>Parameters</title>
66
67     <variablelist>
68
69      <varlistentry>
70       <term><replaceable class="PARAMETER">name</replaceable></term>
71       <listitem>
72        <para>
73         The name (possibly schema-qualified) of an existing index to
74         alter.
75        </para>
76       </listitem>
77      </varlistentry>
78
79      <varlistentry>
80       <term><replaceable class="PARAMETER">new_name</replaceable></term>
81       <listitem>
82        <para>
83         New name for the index.
84        </para>
85       </listitem>
86      </varlistentry>
87
88      <varlistentry>
89       <term><replaceable class="PARAMETER">tablespace_name</replaceable></term>
90       <listitem>
91        <para>
92         The tablespace to which the index will be moved.
93        </para>
94       </listitem>
95      </varlistentry>
96
97     </variablelist>
98  </refsect1>
99
100  <refsect1>
101   <title>Notes</title>
102
103    <para>
104     These operations are also possible using
105     <xref linkend="SQL-ALTERTABLE" endterm="SQL-ALTERTABLE-TITLE">.
106     <command>ALTER INDEX</> is in fact just an alias for the forms
107     of <command>ALTER TABLE</> that apply to indexes.
108    </para>
109
110    <para>
111     There was formerly an <command>ALTER INDEX OWNER</> variant, but
112     this is now ignored (with a warning).  An index cannot have an owner
113     different from its table's owner.  Changing the table's owner
114     automatically changes the index as well.
115    </para>
116
117    <para>
118     Changing any part of a system catalog index is not permitted.
119    </para>
120  </refsect1>
121
122  <refsect1>
123   <title>Examples</title>
124   <para>
125    To rename an existing index:
126 <programlisting>
127 ALTER INDEX distributors RENAME TO suppliers;
128 </programlisting>
129   </para>
130
131   <para> 
132    To move an index to a different tablespace:
133 <programlisting>
134 ALTER INDEX distributors SET TABLESPACE fasttablespace;
135 </programlisting>
136   </para>
137
138  </refsect1>
139
140  <refsect1>
141   <title>Compatibility</title>
142
143   <para>
144    <command>ALTER INDEX</> is a <productname>PostgreSQL</productname>
145    extension.
146   </para>
147  </refsect1>
148 </refentry>
149
150 <!-- Keep this comment at the end of the file
151 Local variables:
152 mode: sgml
153 sgml-omittag:nil
154 sgml-shorttag:t
155 sgml-minimize-attributes:nil
156 sgml-always-quote-attributes:t
157 sgml-indent-step:1
158 sgml-indent-data:t
159 sgml-parent-document:nil
160 sgml-default-dtd-file:"../reference.ced"
161 sgml-exposed-tags:nil
162 sgml-local-catalogs:"/usr/lib/sgml/catalog"
163 sgml-local-ecat-files:nil
164 End:
165 -->