ALTER ROUTINE

ALTER ROUTINE

7

SQL - Language Statements

ALTER ROUTINE

change the definition of a routine

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
[???](#sql-alteraggregate), [???](#sql-alterfunction), and
[???](#sql-alterprocedure) 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
[???](#sql-alterfunction) and [???](#sql-alterprocedure) for more
details. Allowing routine names to refer to aggregate functions is a
PostgreSQL extension.

See Also
========

Note that there is no `CREATE ROUTINE` command.
