# ALTER_ROUTINE - change the definition of a routine - man(7) - [phpMan]

_ALTER_ [_ROUTINE_(7)](https://www.chedong.com/phpMan.php/man/ROUTINE/7/markdown)                   PostgreSQL 16.14 Documentation                   _ALTER_ [_ROUTINE_(7)](https://www.chedong.com/phpMan.php/man/ROUTINE/7/markdown)

## NAME
       ALTER_ROUTINE - change the definition of a routine

## SYNOPSIS
       ALTER ROUTINE _name_ [ ( [ [ _argmode_ ] [ _argname_ ] _argtype_ [, ...] ] ) ]
           _action_ [ ... ] [ RESTRICT ]
       ALTER ROUTINE _name_ [ ( [ [ _argmode_ ] [ _argname_ ] _argtype_ [, ...] ] ) ]
           RENAME TO _new_name_
       ALTER ROUTINE _name_ [ ( [ [ _argmode_ ] [ _argname_ ] _argtype_ [, ...] ] ) ]
           OWNER TO { _new_owner_ | CURRENT_ROLE | CURRENT_USER | SESSION_USER }
       ALTER ROUTINE _name_ [ ( [ [ _argmode_ ] [ _argname_ ] _argtype_ [, ...] ] ) ]
           SET SCHEMA _new_schema_
       ALTER ROUTINE _name_ [ ( [ [ _argmode_ ] [ _argname_ ] _argtype_ [, ...] ] ) ]
           [ NO ] DEPENDS ON EXTENSION _extension_name_

       where _action_ is one of:

           IMMUTABLE | STABLE | VOLATILE
           [ NOT ] LEAKPROOF
           [ EXTERNAL ] SECURITY INVOKER | [ EXTERNAL ] SECURITY DEFINER
           PARALLEL { UNSAFE | RESTRICTED | SAFE }
           COST _execution_cost_
           ROWS _result_rows_
           SET _configuration_parameter_ { TO | = } { _value_ | DEFAULT }
           SET _configuration_parameter_ FROM CURRENT
           RESET _configuration_parameter_
           RESET ALL

## DESCRIPTION
       **ALTER ROUTINE **changes the definition of a routine, which can be an aggregate function, a
       normal function, or a procedure. See under ALTER AGGREGATE ([**ALTER_AGGREGATE**(7)](https://www.chedong.com/phpMan.php/man/ALTERAGGREGATE/7/markdown)), ALTER
       FUNCTION ([**ALTER_FUNCTION**(7)](https://www.chedong.com/phpMan.php/man/ALTERFUNCTION/7/markdown)), and ALTER PROCEDURE ([**ALTER_PROCEDURE**(7)](https://www.chedong.com/phpMan.php/man/ALTERPROCEDURE/7/markdown)) for the description of
       the parameters, more examples, and further details.

## EXAMPLES
       To rename the routine foo for type integer to foobar:

           ALTER ROUTINE foo(integer) RENAME TO foobar;

       This command will work independent of whether foo is an aggregate, function, or procedure.

## COMPATIBILITY
       This statement is partially compatible with the **ALTER ROUTINE **statement in the SQL standard.
       See under ALTER FUNCTION ([**ALTER_FUNCTION**(7)](https://www.chedong.com/phpMan.php/man/ALTERFUNCTION/7/markdown)) and ALTER PROCEDURE ([**ALTER_PROCEDURE**(7)](https://www.chedong.com/phpMan.php/man/ALTERPROCEDURE/7/markdown)) for
       more details. Allowing routine names to refer to aggregate functions is a PostgreSQL
       extension.

## SEE ALSO
       ALTER AGGREGATE ([**ALTER_AGGREGATE**(7)](https://www.chedong.com/phpMan.php/man/ALTERAGGREGATE/7/markdown)), ALTER FUNCTION ([**ALTER_FUNCTION**(7)](https://www.chedong.com/phpMan.php/man/ALTERFUNCTION/7/markdown)), ALTER PROCEDURE
       ([**ALTER_PROCEDURE**(7)](https://www.chedong.com/phpMan.php/man/ALTERPROCEDURE/7/markdown)), DROP ROUTINE ([**DROP_ROUTINE**(7)](https://www.chedong.com/phpMan.php/man/DROPROUTINE/7/markdown))

       Note that there is no CREATE ROUTINE command.

PostgreSQL 16.14                                2026                                _ALTER_ [_ROUTINE_(7)](https://www.chedong.com/phpMan.php/man/ROUTINE/7/markdown)
