3 PostgreSQL documentation
6 <refentry id=
"SQL-ALTERINDEX">
8 <refentrytitle id=
"sql-alterindex-title">ALTER INDEX
</refentrytitle>
9 <refmiscinfo>SQL - Language Statements
</refmiscinfo>
13 <refname>ALTER INDEX
</refname>
14 <refpurpose>change the definition of an index
</refpurpose>
17 <indexterm zone=
"sql-alterindex">
18 <primary>ALTER INDEX
</primary>
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 ALTER INDEX
<replaceable class=
"PARAMETER">name
</replaceable> SET (
<replaceable class=
"PARAMETER">storage_parameter
</replaceable> =
<replaceable class=
"PARAMETER">value
</replaceable> [, ... ] )
26 ALTER INDEX
<replaceable class=
"PARAMETER">name
</replaceable> RESET (
<replaceable class=
"PARAMETER">storage_parameter
</replaceable> [, ... ] )
31 <title>Description
</title>
34 <command>ALTER INDEX
</command> changes the definition of an existing index.
35 There are several subforms:
40 <term><literal>RENAME
</literal></term>
43 The
<literal>RENAME
</literal> form changes the name of the index.
44 There is no effect on the stored data.
50 <term><literal>SET TABLESPACE
</literal></term>
53 This form changes the index's tablespace to the specified tablespace and
54 moves the data file(s) associated with the index to the new tablespace.
56 <xref linkend=
"SQL-CREATETABLESPACE" endterm=
"sql-createtablespace-title">.
62 <term><literal>SET (
<replaceable class=
"PARAMETER">storage_parameter
</replaceable> =
<replaceable class=
"PARAMETER">value
</replaceable> [, ... ] )
</literal></term>
65 This form changes one or more index-method-specific storage parameters
67 <xref linkend=
"SQL-CREATEINDEX" endterm=
"sql-createindex-title">
68 for details on the available parameters. Note that the index contents
69 will not be modified immediately by this command; depending on the
70 parameter you might need to rebuild the index with
71 <xref linkend=
"SQL-REINDEX" endterm=
"sql-reindex-title">
72 to get the desired effects.
78 <term><literal>RESET (
<replaceable class=
"PARAMETER">storage_parameter
</replaceable> [, ... ] )
</literal></term>
81 This form resets one or more index-method-specific storage parameters to
82 their defaults. As with
<literal>SET<
/>, a
<literal>REINDEX
</literal>
83 might be needed to update the index entirely.
94 <title>Parameters
</title>
99 <term><replaceable class=
"PARAMETER">name
</replaceable></term>
102 The name (possibly schema-qualified) of an existing index to
109 <term><replaceable class=
"PARAMETER">new_name
</replaceable></term>
112 The new name for the index.
118 <term><replaceable class=
"PARAMETER">tablespace_name
</replaceable></term>
121 The tablespace to which the index will be moved.
127 <term><replaceable class=
"PARAMETER">storage_parameter
</replaceable></term>
130 The name of an index-method-specific storage parameter.
136 <term><replaceable class=
"PARAMETER">value
</replaceable></term>
139 The new value for an index-method-specific storage parameter.
140 This might be a number or a word depending on the parameter.
152 These operations are also possible using
153 <xref linkend=
"SQL-ALTERTABLE" endterm=
"SQL-ALTERTABLE-TITLE">.
154 <command>ALTER INDEX<
/> is in fact just an alias for the forms
155 of
<command>ALTER TABLE<
/> that apply to indexes.
159 There was formerly an
<command>ALTER INDEX OWNER<
/> variant, but
160 this is now ignored (with a warning). An index cannot have an owner
161 different from its table's owner. Changing the table's owner
162 automatically changes the index as well.
166 Changing any part of a system catalog index is not permitted.
171 <title>Examples
</title>
173 To rename an existing index:
175 ALTER INDEX distributors RENAME TO suppliers;
180 To move an index to a different tablespace:
182 ALTER INDEX distributors SET TABLESPACE fasttablespace;
187 To change an index's fill factor (assuming that the index method
190 ALTER INDEX distributors SET (fillfactor =
75);
191 REINDEX INDEX distributors;
198 <title>Compatibility
</title>
201 <command>ALTER INDEX<
/> is a
<productname>PostgreSQL
</productname>
208 <title>See Also
</title>
210 <simplelist type=
"inline">
211 <member><xref linkend=
"sql-createindex" endterm=
"sql-createindex-title"></member>
212 <member><xref linkend=
"sql-reindex" endterm=
"sql-reindex-title"></member>