Modifies an index.

Syntax

PolarDB-O support two variants of the ALTER INDEX command. You can use the first variant to rename an index:

ALTER INDEX name RENAME TO new_name

You can use the second variant to reconstruct an index.

ALTER INDEX name REBUILD

Description

You can use the ALTER INDEX command to modify an index. The RENAME clause allows you to change the name of an index. The REBUILD clause allows you to reconstruct an index and replaces the previous copy of the index with an updated version based on the index table.

You can call the PostgreSQL REINDEX command when using the REBUILD clause. For more information about how to use the REBUILD clause, see the PostgreSQL documentation.

The ALTER INDEX command does not affect stored data.

Parameters

Parameter Description
name The name of the index. The name can be schema-qualified.
new_name The new name of the index.

Examples

The following example shows how to change the name of an index from name_idx to empname_idx:

ALTER INDEX name_idx RENAME TO empname_idx;

The following example shows how to reconstruct an index named empname_idx:

ALTER INDEX empname_idx REBUILD;