ALTER ROUTINE

|      ALTER ROUTINE       |                       |            |                  |                           |
|:------------------------:|-----------------------|------------|------------------|---------------------------|
|[Prev](sql-alterrole.html)|[Up](sql-commands.html)|SQL Commands|[Home](index.html)| [Next](sql-alterrule.html)|

---

[]()

## ALTER ROUTINE

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

## See Also

[ALTER AGGREGATE](sql-alteraggregate.html), [ALTER FUNCTION](sql-alterfunction.html), [ALTER PROCEDURE](sql-alterprocedure.html), [DROP ROUTINE](sql-droproutine.html)

 Note that there is no `CREATE ROUTINE` command.

---

|[Prev](sql-alterrole.html)|[Up](sql-commands.html)| [Next](sql-alterrule.html)|
|:-------------------------|:---------------------:|--------------------------:|
|        ALTER ROLE        |  [Home](index.html)   |         ALTER RULE        |

 // \<![CDATA[ \<-- For SVG support if ('WebSocket' in window) { (function() { function refreshCSS() { var sheets = [].slice.call(document.getElementsByTagName("link")); var head = document.getElementsByTagName("head")[0]; for (var i = 0; i \< sheets.length; ++i) { var elem = sheets[i]; head.removeChild(elem); var rel = elem.rel; if (elem.href && typeof rel != "string" || rel.length == 0 || rel.toLowerCase() == "stylesheet") { var url = elem.href.replace(/(&|\\?)\_cacheOverride=\\d+/, ''); elem.href = url + (url.indexOf('?') \>= 0 ? '&' : '?') + '\_cacheOverride=' + (new Date().valueOf()); } head.appendChild(elem); } } var protocol = window.location.protocol === 'http:' ? 'ws://' : 'wss://'; var address = protocol + window.location.host + window.location.pathname + '/ws'; var socket = new WebSocket(address); socket.onmessage = function(msg) { if (msg.data == 'reload') window.location.reload(); else if (msg.data == 'refreshcss') refreshCSS(); }; console.log('Live reload enabled.'); })(); } // ]]\>