aboutsummaryrefslogtreecommitdiff
path: root/doc/src/sgml/ref/alter_index.sgml
blob: c212fd09f93f59b214522f1ef9de2f573dc834d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/alter_index.sgml,v 1.6 2005/08/22 19:39:52 tgl Exp $
PostgreSQL documentation
-->

<refentry id="SQL-ALTERINDEX">
 <refmeta>
  <refentrytitle id="sql-alterindex-title">ALTER INDEX</refentrytitle>
  <refmiscinfo>SQL - Language Statements</refmiscinfo>
 </refmeta>

 <refnamediv>
  <refname>ALTER INDEX</refname>
  <refpurpose>change the definition of an index</refpurpose>
 </refnamediv>

 <indexterm zone="sql-alterindex">
  <primary>ALTER INDEX</primary>
 </indexterm>

 <refsynopsisdiv>
<synopsis>
ALTER INDEX <replaceable class="PARAMETER">name</replaceable> RENAME TO <replaceable class="PARAMETER">new_name</replaceable>
ALTER INDEX <replaceable class="PARAMETER">name</replaceable> SET TABLESPACE <replaceable class="PARAMETER">tablespace_name</replaceable>
</synopsis>
 </refsynopsisdiv>

 <refsect1>
  <title>Description</title>

  <para>
   <command>ALTER INDEX</command> changes the definition of an existing index.
   There are several subforms:

  <variablelist>

   <varlistentry>
    <term><literal>RENAME</literal></term>
    <listitem>
     <para>
      The <literal>RENAME</literal> form changes the name of the index. 
      There is no effect on the stored data.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><literal>SET TABLESPACE</literal></term>
    <listitem>
     <para>
      This form changes the index's tablespace to the specified tablespace and
      moves the data file(s) associated with the index to the new tablespace.
      See also 
      <xref linkend="SQL-CREATETABLESPACE" endterm="sql-createtablespace-title">.
     </para>
    </listitem>
   </varlistentry>

  </variablelist>
  </para>

 </refsect1>

 <refsect1>
  <title>Parameters</title>

    <variablelist>

     <varlistentry>
      <term><replaceable class="PARAMETER">name</replaceable></term>
      <listitem>
       <para>
        The name (possibly schema-qualified) of an existing index to
        alter.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><replaceable class="PARAMETER">new_name</replaceable></term>
      <listitem>
       <para>
        New name for the index.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><replaceable class="PARAMETER">tablespace_name</replaceable></term>
      <listitem>
       <para>
        The tablespace to which the index will be moved.
       </para>
      </listitem>
     </varlistentry>

    </variablelist>
 </refsect1>

 <refsect1>
  <title>Notes</title>

   <para>
    These operations are also possible using
    <xref linkend="SQL-ALTERTABLE" endterm="SQL-ALTERTABLE-TITLE">.
    <command>ALTER INDEX</> is in fact just an alias for the forms
    of <command>ALTER TABLE</> that apply to indexes.
   </para>

   <para>
    There was formerly an <command>ALTER INDEX OWNER</> variant, but
    this is now ignored (with a warning).  An index cannot have an owner
    different from its table's owner.  Changing the table's owner
    automatically changes the index as well.
   </para>

   <para>
    Changing any part of a system catalog index is not permitted.
   </para>
 </refsect1>

 <refsect1>
  <title>Examples</title>
  <para>
   To rename an existing index:
<programlisting>
ALTER INDEX distributors RENAME TO suppliers;
</programlisting>
  </para>

  <para> 
   To move an index to a different tablespace:
<programlisting>
ALTER INDEX distributors SET TABLESPACE fasttablespace;
</programlisting>
  </para>

 </refsect1>

 <refsect1>
  <title>Compatibility</title>

  <para>
   <command>ALTER INDEX</> is a <productname>PostgreSQL</productname>
   extension.
  </para>
 </refsect1>
</refentry>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:nil
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
sgml-parent-document:nil
sgml-default-dtd-file:"../reference.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:"/usr/lib/sgml/catalog"
sgml-local-ecat-files:nil
End:
-->