{
    "mode": "man",
    "parameter": "ALTER_FUNCTION",
    "section": "7",
    "url": "https://www.chedong.com/phpMan.php/man/ALTER_FUNCTION/7/json",
    "generated": "2026-07-05T11:45:56Z",
    "synopsis": "ALTER FUNCTION name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ]\naction [ ... ] [ RESTRICT ]\nALTER FUNCTION name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ]\nRENAME TO newname\nALTER FUNCTION name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ]\nOWNER TO { newowner | CURRENTROLE | CURRENTUSER | SESSIONUSER }\nALTER FUNCTION name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ]\nSET SCHEMA newschema\nALTER FUNCTION name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ]\n[ NO ] DEPENDS ON EXTENSION extensionname\nwhere action is one of:\nCALLED ON NULL INPUT | RETURNS NULL ON NULL INPUT | STRICT\nIMMUTABLE | STABLE | VOLATILE\n[ NOT ] LEAKPROOF\n[ EXTERNAL ] SECURITY INVOKER | [ EXTERNAL ] SECURITY DEFINER\nPARALLEL { UNSAFE | RESTRICTED | SAFE }\nCOST executioncost\nROWS resultrows\nSUPPORT supportfunction\nSET configurationparameter { TO | = } { value | DEFAULT }\nSET configurationparameter FROM CURRENT\nRESET configurationparameter\nRESET ALL",
    "sections": {
        "NAME": {
            "content": "ALTERFUNCTION - change the definition of a function\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "ALTER FUNCTION name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ]\naction [ ... ] [ RESTRICT ]\nALTER FUNCTION name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ]\nRENAME TO newname\nALTER FUNCTION name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ]\nOWNER TO { newowner | CURRENTROLE | CURRENTUSER | SESSIONUSER }\nALTER FUNCTION name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ]\nSET SCHEMA newschema\nALTER FUNCTION name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ]\n[ NO ] DEPENDS ON EXTENSION extensionname\n\nwhere action is one of:\n\nCALLED ON NULL INPUT | RETURNS NULL ON NULL INPUT | STRICT\nIMMUTABLE | STABLE | VOLATILE\n[ NOT ] LEAKPROOF\n[ EXTERNAL ] SECURITY INVOKER | [ EXTERNAL ] SECURITY DEFINER\nPARALLEL { UNSAFE | RESTRICTED | SAFE }\nCOST executioncost\nROWS resultrows\nSUPPORT supportfunction\nSET configurationparameter { TO | = } { value | DEFAULT }\nSET configurationparameter FROM CURRENT\nRESET configurationparameter\nRESET ALL\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "ALTER FUNCTION changes the definition of a function.\n\nYou must own the function to use ALTER FUNCTION. To change a function's schema, you must also\nhave CREATE privilege on the new schema. To alter the owner, you must also be a direct or\nindirect member of the new owning role, and that role must have CREATE privilege on the\nfunction's schema. (These restrictions enforce that altering the owner doesn't do anything\nyou couldn't do by dropping and recreating the function. However, a superuser can alter\nownership of any function anyway.)\n",
            "subsections": []
        },
        "PARAMETERS": {
            "content": "name\nThe name (optionally schema-qualified) of an existing function. If no argument list is\nspecified, the name must be unique in its schema.\n\nargmode\nThe mode of an argument: IN, OUT, INOUT, or VARIADIC. If omitted, the default is IN. Note\nthat ALTER FUNCTION does not actually pay any attention to OUT arguments, since only the\ninput arguments are needed to determine the function's identity. So it is sufficient to\nlist the IN, INOUT, and VARIADIC arguments.\n\nargname\nThe name of an argument. Note that ALTER FUNCTION does not actually pay any attention to\nargument names, since only the argument data types are needed to determine the function's\nidentity.\n\nargtype\nThe data type(s) of the function's arguments (optionally schema-qualified), if any.\n\nnewname\nThe new name of the function.\n\nnewowner\nThe new owner of the function. Note that if the function is marked SECURITY DEFINER, it\nwill subsequently execute as the new owner.\n\nnewschema\nThe new schema for the function.\n\nDEPENDS ON EXTENSION extensionname\nNO DEPENDS ON EXTENSION extensionname\nThis form marks the function as dependent on the extension, or no longer dependent on\nthat extension if NO is specified. A function that's marked as dependent on an extension\nis dropped when the extension is dropped, even if CASCADE is not specified. A function\ncan depend upon multiple extensions, and will be dropped when any one of those extensions\nis dropped.\n\nCALLED ON NULL INPUT\nRETURNS NULL ON NULL INPUT\nSTRICT\nCALLED ON NULL INPUT changes the function so that it will be invoked when some or all of\nits arguments are null.  RETURNS NULL ON NULL INPUT or STRICT changes the function so\nthat it is not invoked if any of its arguments are null; instead, a null result is\nassumed automatically. See CREATE FUNCTION (CREATEFUNCTION(7)) for more information.\n\nIMMUTABLE\nSTABLE\nVOLATILE\nChange the volatility of the function to the specified setting. See CREATE FUNCTION\n(CREATEFUNCTION(7)) for details.\n\n[ EXTERNAL ] SECURITY INVOKER\n[ EXTERNAL ] SECURITY DEFINER\nChange whether the function is a security definer or not. The key word EXTERNAL is\nignored for SQL conformance. See CREATE FUNCTION (CREATEFUNCTION(7)) for more\ninformation about this capability.\n\nPARALLEL\nChange whether the function is deemed safe for parallelism. See CREATE FUNCTION\n(CREATEFUNCTION(7)) for details.\n\nLEAKPROOF\nChange whether the function is considered leakproof or not. See CREATE FUNCTION\n(CREATEFUNCTION(7)) for more information about this capability.\n\nCOST executioncost\nChange the estimated execution cost of the function. See CREATE FUNCTION\n(CREATEFUNCTION(7)) for more information.\n\nROWS resultrows\nChange the estimated number of rows returned by a set-returning function. See CREATE\nFUNCTION (CREATEFUNCTION(7)) for more information.\n\nSUPPORT supportfunction\nSet or change the planner support function to use for this function. See Section 38.11\nfor details. You must be superuser to use this option.\n\nThis option cannot be used to remove the support function altogether, since it must name\na new support function. Use CREATE OR REPLACE FUNCTION if you need to do that.\n\nconfigurationparameter\nvalue\nAdd or change the assignment to be made to a configuration parameter when the function is\ncalled. If value is DEFAULT or, equivalently, RESET is used, the function-local setting\nis removed, so that the function executes with the value present in its environment. Use\nRESET ALL to clear all function-local settings.  SET FROM CURRENT saves the value of the\nparameter that is current when ALTER FUNCTION is executed as the value to be applied when\nthe function is entered.\n\nSee SET(7) and Chapter 20 for more information about allowed parameter names and values.\n\nRESTRICT\nIgnored for conformance with the SQL standard.\n",
            "subsections": []
        },
        "EXAMPLES": {
            "content": "To rename the function sqrt for type integer to squareroot:\n\nALTER FUNCTION sqrt(integer) RENAME TO squareroot;\n\nTo change the owner of the function sqrt for type integer to joe:\n\nALTER FUNCTION sqrt(integer) OWNER TO joe;\n\nTo change the schema of the function sqrt for type integer to maths:\n\nALTER FUNCTION sqrt(integer) SET SCHEMA maths;\n\nTo mark the function sqrt for type integer as being dependent on the extension mathlib:\n\nALTER FUNCTION sqrt(integer) DEPENDS ON EXTENSION mathlib;\n\nTo adjust the search path that is automatically set for a function:\n\nALTER FUNCTION checkpassword(text) SET searchpath = admin, pgtemp;\n\nTo disable automatic setting of searchpath for a function:\n\nALTER FUNCTION checkpassword(text) RESET searchpath;\n\nThe function will now execute with whatever search path is used by its caller.\n",
            "subsections": []
        },
        "COMPATIBILITY": {
            "content": "This statement is partially compatible with the ALTER FUNCTION statement in the SQL standard.\nThe standard allows more properties of a function to be modified, but does not provide the\nability to rename a function, make a function a security definer, attach configuration\nparameter values to a function, or change the owner, schema, or volatility of a function. The\nstandard also requires the RESTRICT key word, which is optional in PostgreSQL.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "CREATE FUNCTION (CREATEFUNCTION(7)), DROP FUNCTION (DROPFUNCTION(7)), ALTER PROCEDURE\n(ALTERPROCEDURE(7)), ALTER ROUTINE (ALTERROUTINE(7))\n\n\n\nPostgreSQL 14.23                                2026                               ALTER FUNCTION(7)",
            "subsections": []
        }
    },
    "summary": "ALTERFUNCTION - change the definition of a function",
    "flags": [],
    "examples": [
        "To rename the function sqrt for type integer to squareroot:",
        "ALTER FUNCTION sqrt(integer) RENAME TO squareroot;",
        "To change the owner of the function sqrt for type integer to joe:",
        "ALTER FUNCTION sqrt(integer) OWNER TO joe;",
        "To change the schema of the function sqrt for type integer to maths:",
        "ALTER FUNCTION sqrt(integer) SET SCHEMA maths;",
        "To mark the function sqrt for type integer as being dependent on the extension mathlib:",
        "ALTER FUNCTION sqrt(integer) DEPENDS ON EXTENSION mathlib;",
        "To adjust the search path that is automatically set for a function:",
        "ALTER FUNCTION checkpassword(text) SET searchpath = admin, pgtemp;",
        "To disable automatic setting of searchpath for a function:",
        "ALTER FUNCTION checkpassword(text) RESET searchpath;",
        "The function will now execute with whatever search path is used by its caller."
    ],
    "see_also": [
        {
            "name": "CREATEFUNCTION",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/CREATEFUNCTION/7/json"
        },
        {
            "name": "DROPFUNCTION",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/DROPFUNCTION/7/json"
        },
        {
            "name": "ALTERPROCEDURE",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/ALTERPROCEDURE/7/json"
        },
        {
            "name": "ALTERROUTINE",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/ALTERROUTINE/7/json"
        },
        {
            "name": "FUNCTION",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/FUNCTION/7/json"
        }
    ]
}