ALTER_STATISTICS(7pg17)
π NAME π
okay so bestie, welcome to the ALTER STATISTICS page from the PostgreSQL 17.11 Documentation β¨ this is the one that changes the definition of an extended statistics object. yes, that kind of glow-up for your stats π
π¦ SYNOPSIS π¦
ALTER STATISTICS name OWNER TO { new_owner | CURRENT_ROLE | CURRENT_USER | SESSION_USER }
ALTER STATISTICS name RENAME TO new_name
ALTER STATISTICS name SET SCHEMA new_schema
ALTER STATISTICS name SET STATISTICS { new_target | DEFAULT }
πΈ DESCRIPTION πΈ
ALTER STATISTICS changes the parameters of an existing extended statistics object. literally any parameters you donβt specifically set in the ALTER STATISTICS command just keep their prior settings β no cap π«Ά
You must own the statistics object to use ALTER STATISTICS. To change a statistics objectβs schema, you must also have CREATE privilege on the new schema. To alter the owner, you must be able to SET ROLE to the new owning role, and that role must have CREATE privilege on the statistics objectβs schema. (These restrictions enforce that altering the owner doesnβt do anything you couldnβt do by dropping and recreating the statistics object. However, a superuser can alter ownership of any statistics object anyway.) π
π PARAMETERS π
nameβ the name (optionally schema-qualified) of the statistics object to be altered. iykyk, itβs the target of your makeover π«new_ownerβ the user name of the new owner of the statistics object.new_nameβ the new name for the statistics object.new_schemaβ the new schema for the statistics object.new_targetβ the statistic-gathering target for this statistics object for subsequentANALYZEoperations. The target can be set in the range0to10000. Set it toDEFAULTto revert to using the system default statistics target (default_statistics_target). (Setting to a value of-1is an obsolete way spelling to get the same outcome.) For more information on the use of statistics by the PostgreSQL query planner, refer to Section 14.2. π₯
bestie warning-ish note: -1 still gets you the same outcome, but itβs the obsolete spelling β the more you know π
π COMPATIBILITY π
There is no ALTER STATISTICS command in the SQL standard. periodt.
β SEE ALSO β
CREATE STATISTICS(CREATE_STATISTICS(7))DROP STATISTICS(DROP_STATISTICS(7))
and thatβs the whole vibe π this icon was brought to you by PostgreSQL 17.11, dated 2026, and the manual page ALTER STATISTICS(7) β mwah, slay πβ¨
π¦ where this page comes from
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms