{
    "mode": "man",
    "parameter": "ALTER_AGGREGATE",
    "section": "7",
    "url": "https://www.chedong.com/phpMan.php/man/ALTER_AGGREGATE/7/json",
    "generated": "2026-06-15T16:45:18Z",
    "synopsis": "ALTER AGGREGATE name ( aggregatesignature ) RENAME TO newname\nALTER AGGREGATE name ( aggregatesignature )\nOWNER TO { newowner | CURRENTROLE | CURRENTUSER | SESSIONUSER }\nALTER AGGREGATE name ( aggregatesignature ) SET SCHEMA newschema\nwhere aggregatesignature is:\n* |\n[ argmode ] [ argname ] argtype [ , ... ] |\n[ [ argmode ] [ argname ] argtype [ , ... ] ] ORDER BY [ argmode ] [ argname ] argtype [ , ... ]",
    "sections": {
        "NAME": {
            "content": "ALTERAGGREGATE - change the definition of an aggregate function\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "ALTER AGGREGATE name ( aggregatesignature ) RENAME TO newname\nALTER AGGREGATE name ( aggregatesignature )\nOWNER TO { newowner | CURRENTROLE | CURRENTUSER | SESSIONUSER }\nALTER AGGREGATE name ( aggregatesignature ) SET SCHEMA newschema\n\nwhere aggregatesignature is:\n\n* |\n[ argmode ] [ argname ] argtype [ , ... ] |\n[ [ argmode ] [ argname ] argtype [ , ... ] ] ORDER BY [ argmode ] [ argname ] argtype [ , ... ]\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "ALTER AGGREGATE changes the definition of an aggregate function.\n\nYou must own the aggregate function to use ALTER AGGREGATE. To change the schema of an\naggregate function, you must also have CREATE privilege on the new schema. To alter the\nowner, you must also be a direct or indirect member of the new owning role, and that role\nmust have CREATE privilege on the aggregate function's schema. (These restrictions enforce\nthat altering the owner doesn't do anything you couldn't do by dropping and recreating the\naggregate function. However, a superuser can alter ownership of any aggregate function\nanyway.)\n",
            "subsections": []
        },
        "PARAMETERS": {
            "content": "name\nThe name (optionally schema-qualified) of an existing aggregate function.\n\nargmode\nThe mode of an argument: IN or VARIADIC. If omitted, the default is IN.\n\nargname\nThe name of an argument. Note that ALTER AGGREGATE does not actually pay any attention to\nargument names, since only the argument data types are needed to determine the aggregate\nfunction's identity.\n\nargtype\nAn input data type on which the aggregate function operates. To reference a zero-argument\naggregate function, write * in place of the list of argument specifications. To reference\nan ordered-set aggregate function, write ORDER BY between the direct and aggregated\nargument specifications.\n\nnewname\nThe new name of the aggregate function.\n\nnewowner\nThe new owner of the aggregate function.\n\nnewschema\nThe new schema for the aggregate function.\n",
            "subsections": []
        },
        "NOTES": {
            "content": "The recommended syntax for referencing an ordered-set aggregate is to write ORDER BY between\nthe direct and aggregated argument specifications, in the same style as in CREATE AGGREGATE.\nHowever, it will also work to omit ORDER BY and just run the direct and aggregated argument\nspecifications into a single list. In this abbreviated form, if VARIADIC \"any\" was used in\nboth the direct and aggregated argument lists, write VARIADIC \"any\" only once.\n",
            "subsections": []
        },
        "EXAMPLES": {
            "content": "To rename the aggregate function myavg for type integer to myaverage:\n\nALTER AGGREGATE myavg(integer) RENAME TO myaverage;\n\nTo change the owner of the aggregate function myavg for type integer to joe:\n\nALTER AGGREGATE myavg(integer) OWNER TO joe;\n\nTo move the ordered-set aggregate mypercentile with direct argument of type float8 and\naggregated argument of type integer into schema myschema:\n\nALTER AGGREGATE mypercentile(float8 ORDER BY integer) SET SCHEMA myschema;\n\nThis will work too:\n\nALTER AGGREGATE mypercentile(float8, integer) SET SCHEMA myschema;\n",
            "subsections": []
        },
        "COMPATIBILITY": {
            "content": "There is no ALTER AGGREGATE statement in the SQL standard.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "CREATE AGGREGATE (CREATEAGGREGATE(7)), DROP AGGREGATE (DROPAGGREGATE(7))\n\n\n\nPostgreSQL 14.23                                2026                              ALTER AGGREGATE(7)",
            "subsections": []
        }
    },
    "summary": "ALTERAGGREGATE - change the definition of an aggregate function",
    "flags": [],
    "examples": [
        "To rename the aggregate function myavg for type integer to myaverage:",
        "ALTER AGGREGATE myavg(integer) RENAME TO myaverage;",
        "To change the owner of the aggregate function myavg for type integer to joe:",
        "ALTER AGGREGATE myavg(integer) OWNER TO joe;",
        "To move the ordered-set aggregate mypercentile with direct argument of type float8 and",
        "aggregated argument of type integer into schema myschema:",
        "ALTER AGGREGATE mypercentile(float8 ORDER BY integer) SET SCHEMA myschema;",
        "This will work too:",
        "ALTER AGGREGATE mypercentile(float8, integer) SET SCHEMA myschema;"
    ],
    "see_also": [
        {
            "name": "CREATEAGGREGATE",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/CREATEAGGREGATE/7/json"
        },
        {
            "name": "DROPAGGREGATE",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/DROPAGGREGATE/7/json"
        },
        {
            "name": "AGGREGATE",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/AGGREGATE/7/json"
        }
    ]
}