table of contents
ALTER INDEX(7) | PostgreSQL 10.23 Documentation | ALTER INDEX(7) |
NAME¶
ALTER_INDEX - change the definition of an index
SYNOPSIS¶
ALTER INDEX [ IF EXISTS ] name RENAME TO new_name ALTER INDEX [ IF EXISTS ] name SET TABLESPACE tablespace_name ALTER INDEX name DEPENDS ON EXTENSION extension_name ALTER INDEX [ IF EXISTS ] name SET ( storage_parameter [= value] [, ... ] ) ALTER INDEX [ IF EXISTS ] name RESET ( storage_parameter [, ... ] ) ALTER INDEX ALL IN TABLESPACE name [ OWNED BY role_name [, ... ] ]
SET TABLESPACE new_tablespace [ NOWAIT ]
DESCRIPTION¶
ALTER INDEX changes the definition of an existing index. There are several subforms:
RENAME
SET TABLESPACE
DEPENDS ON EXTENSION
SET ( storage_parameter [= value] [, ... ] )
RESET ( storage_parameter [, ... ] )
PARAMETERS¶
IF EXISTS
name
new_name
tablespace_name
extension_name
storage_parameter
value
NOTES¶
These operations are also possible using ALTER TABLE (ALTER_TABLE(7)). ALTER INDEX is in fact just an alias for the forms of ALTER TABLE that apply to indexes.
There was formerly an 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.
Changing any part of a system catalog index is not permitted.
EXAMPLES¶
To rename an existing index:
ALTER INDEX distributors RENAME TO suppliers;
To move an index to a different tablespace:
ALTER INDEX distributors SET TABLESPACE fasttablespace;
To change an index's fill factor (assuming that the index method supports it):
ALTER INDEX distributors SET (fillfactor = 75); REINDEX INDEX distributors;
COMPATIBILITY¶
ALTER INDEX is a PostgreSQL extension.
SEE ALSO¶
CREATE INDEX (CREATE_INDEX(7)), REINDEX(7)
2022 | PostgreSQL 10.23 |