{
    "content": [
        {
            "type": "text",
            "text": "# ALTER_INDEX (man)\n\n## NAME\n\nALTERINDEX - change the definition of an index\n\n## SYNOPSIS\n\nALTER INDEX [ IF EXISTS ] name RENAME TO newname\nALTER INDEX [ IF EXISTS ] name SET TABLESPACE tablespacename\nALTER INDEX name ATTACH PARTITION indexname\nALTER INDEX name [ NO ] DEPENDS ON EXTENSION extensionname\nALTER INDEX [ IF EXISTS ] name SET ( storageparameter [= value] [, ... ] )\nALTER INDEX [ IF EXISTS ] name RESET ( storageparameter [, ... ] )\nALTER INDEX [ IF EXISTS ] name ALTER [ COLUMN ] columnnumber\nSET STATISTICS integer\nALTER INDEX ALL IN TABLESPACE name [ OWNED BY rolename [, ... ] ]\nSET TABLESPACE newtablespace [ NOWAIT ]\n\n## DESCRIPTION\n\nALTER INDEX changes the definition of an existing index. There are several subforms described\nbelow. Note that the lock level required may differ for each subform. An ACCESS EXCLUSIVE\nlock is held unless explicitly noted. When multiple subcommands are listed, the lock held\nwill be the strictest one required from any subcommand.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **PARAMETERS**\n- **NOTES**\n- **EXAMPLES**\n- **COMPATIBILITY**\n- **SEE ALSO**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "ALTER_INDEX",
        "section": "",
        "mode": "man",
        "summary": "ALTERINDEX - change the definition of an index",
        "synopsis": "ALTER INDEX [ IF EXISTS ] name RENAME TO newname\nALTER INDEX [ IF EXISTS ] name SET TABLESPACE tablespacename\nALTER INDEX name ATTACH PARTITION indexname\nALTER INDEX name [ NO ] DEPENDS ON EXTENSION extensionname\nALTER INDEX [ IF EXISTS ] name SET ( storageparameter [= value] [, ... ] )\nALTER INDEX [ IF EXISTS ] name RESET ( storageparameter [, ... ] )\nALTER INDEX [ IF EXISTS ] name ALTER [ COLUMN ] columnnumber\nSET STATISTICS integer\nALTER INDEX ALL IN TABLESPACE name [ OWNED BY rolename [, ... ] ]\nSET TABLESPACE newtablespace [ NOWAIT ]",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "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;",
            "Set the statistics-gathering target for an expression index:",
            "CREATE INDEX coordidx ON measured (x, y, (z + t));",
            "ALTER INDEX coordidx ALTER COLUMN 3 SET STATISTICS 1000;"
        ],
        "see_also": [
            {
                "name": "CREATEINDEX",
                "section": "7",
                "url": "https://www.chedong.com/phpMan.php/man/CREATEINDEX/7/json"
            },
            {
                "name": "REINDEX",
                "section": "7",
                "url": "https://www.chedong.com/phpMan.php/man/REINDEX/7/json"
            },
            {
                "name": "INDEX",
                "section": "7",
                "url": "https://www.chedong.com/phpMan.php/man/INDEX/7/json"
            }
        ],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 11,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 58,
                "subsections": []
            },
            {
                "name": "PARAMETERS",
                "lines": 25,
                "subsections": []
            },
            {
                "name": "NOTES",
                "lines": 9,
                "subsections": []
            },
            {
                "name": "EXAMPLES",
                "lines": 18,
                "subsections": []
            },
            {
                "name": "COMPATIBILITY",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 3,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "ALTERINDEX - change the definition of an index\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "ALTER INDEX [ IF EXISTS ] name RENAME TO newname\nALTER INDEX [ IF EXISTS ] name SET TABLESPACE tablespacename\nALTER INDEX name ATTACH PARTITION indexname\nALTER INDEX name [ NO ] DEPENDS ON EXTENSION extensionname\nALTER INDEX [ IF EXISTS ] name SET ( storageparameter [= value] [, ... ] )\nALTER INDEX [ IF EXISTS ] name RESET ( storageparameter [, ... ] )\nALTER INDEX [ IF EXISTS ] name ALTER [ COLUMN ] columnnumber\nSET STATISTICS integer\nALTER INDEX ALL IN TABLESPACE name [ OWNED BY rolename [, ... ] ]\nSET TABLESPACE newtablespace [ NOWAIT ]\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "ALTER INDEX changes the definition of an existing index. There are several subforms described\nbelow. Note that the lock level required may differ for each subform. An ACCESS EXCLUSIVE\nlock is held unless explicitly noted. When multiple subcommands are listed, the lock held\nwill be the strictest one required from any subcommand.\n\nRENAME\nThe RENAME form changes the name of the index. If the index is associated with a table\nconstraint (either UNIQUE, PRIMARY KEY, or EXCLUDE), the constraint is renamed as well.\nThere is no effect on the stored data.\n\nRenaming an index acquires a SHARE UPDATE EXCLUSIVE lock.\n\nSET TABLESPACE\nThis form changes the index's tablespace to the specified tablespace and moves the data\nfile(s) associated with the index to the new tablespace. To change the tablespace of an\nindex, you must own the index and have CREATE privilege on the new tablespace. All\nindexes in the current database in a tablespace can be moved by using the ALL IN\nTABLESPACE form, which will lock all indexes to be moved and then move each one. This\nform also supports OWNED BY, which will only move indexes owned by the roles specified.\nIf the NOWAIT option is specified then the command will fail if it is unable to acquire\nall of the locks required immediately. Note that system catalogs will not be moved by\nthis command, use ALTER DATABASE or explicit ALTER INDEX invocations instead if desired.\nSee also CREATE TABLESPACE.\n\nATTACH PARTITION indexname\nCauses the named index (possibly schema-qualified) to become attached to the altered\nindex. The named index must be on a partition of the table containing the index being\naltered, and have an equivalent definition. An attached index cannot be dropped by\nitself, and will automatically be dropped if its parent index is dropped.\n\nIf the named index is already attached to the altered index, the command will attempt to\nvalidate the parent index if the parent is currently invalid.\n\nDEPENDS ON EXTENSION extensionname\nNO DEPENDS ON EXTENSION extensionname\nThis form marks the index as dependent on the extension, or no longer dependent on that\nextension if NO is specified. An index that's marked as dependent on an extension is\nautomatically dropped when the extension is dropped.\n\nSET ( storageparameter [= value] [, ... ] )\nThis form changes one or more index-method-specific storage parameters for the index. See\nCREATE INDEX for details on the available parameters. Note that the index contents will\nnot be modified immediately by this command; depending on the parameter you might need to\nrebuild the index with REINDEX to get the desired effects.\n\nRESET ( storageparameter [, ... ] )\nThis form resets one or more index-method-specific storage parameters to their defaults.\nAs with SET, a REINDEX might be needed to update the index entirely.\n\nALTER [ COLUMN ] columnnumber SET STATISTICS integer\nThis form sets the per-column statistics-gathering target for subsequent ANALYZE\noperations, though can be used only on index columns that are defined as an expression.\nSince expressions lack a unique name, we refer to them using the ordinal number of the\nindex column. The target can be set in the range 0 to 10000; alternatively, set it to -1\nto revert to using the system default statistics target (defaultstatisticstarget). For\nmore information on the use of statistics by the PostgreSQL query planner, refer to\nSection 14.2.\n",
                "subsections": []
            },
            "PARAMETERS": {
                "content": "IF EXISTS\nDo not throw an error if the index does not exist. A notice is issued in this case.\n\ncolumnnumber\nThe ordinal number refers to the ordinal (left-to-right) position of the index column.\n\nname\nThe name (possibly schema-qualified) of an existing index to alter.\n\nnewname\nThe new name for the index.\n\ntablespacename\nThe tablespace to which the index will be moved.\n\nextensionname\nThe name of the extension that the index is to depend on.\n\nstorageparameter\nThe name of an index-method-specific storage parameter.\n\nvalue\nThe new value for an index-method-specific storage parameter. This might be a number or a\nword depending on the parameter.\n",
                "subsections": []
            },
            "NOTES": {
                "content": "These operations are also possible using ALTER TABLE.  ALTER INDEX is in fact just an alias\nfor the forms of ALTER TABLE that apply to indexes.\n\nThere was formerly an ALTER INDEX OWNER variant, but this is now ignored (with a warning). An\nindex cannot have an owner different from its table's owner. Changing the table's owner\nautomatically changes the index as well.\n\nChanging any part of a system catalog index is not permitted.\n",
                "subsections": []
            },
            "EXAMPLES": {
                "content": "To rename an existing index:\n\nALTER INDEX distributors RENAME TO suppliers;\n\nTo move an index to a different tablespace:\n\nALTER INDEX distributors SET TABLESPACE fasttablespace;\n\nTo change an index's fill factor (assuming that the index method supports it):\n\nALTER INDEX distributors SET (fillfactor = 75);\nREINDEX INDEX distributors;\n\nSet the statistics-gathering target for an expression index:\n\nCREATE INDEX coordidx ON measured (x, y, (z + t));\nALTER INDEX coordidx ALTER COLUMN 3 SET STATISTICS 1000;\n",
                "subsections": []
            },
            "COMPATIBILITY": {
                "content": "ALTER INDEX is a PostgreSQL extension.\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "CREATE INDEX (CREATEINDEX(7)), REINDEX(7)\n\nPostgreSQL 14.23                               2026                                ALTER INDEX(7)",
                "subsections": []
            }
        }
    }
}