1 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>ALTER ROUTINE</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="sql-alterrole.html" title="ALTER ROLE" /><link rel="next" href="sql-alterrule.html" title="ALTER RULE" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">ALTER ROUTINE</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="sql-alterrole.html" title="ALTER ROLE">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="sql-commands.html" title="SQL Commands">Up</a></td><th width="60%" align="center">SQL Commands</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 18.0 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="sql-alterrule.html" title="ALTER RULE">Next</a></td></tr></table><hr /></div><div class="refentry" id="SQL-ALTERROUTINE"><div class="titlepage"></div><a id="id-1.9.3.27.1" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle">ALTER ROUTINE</span></h2><p>ALTER ROUTINE — change the definition of a routine</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="synopsis">
3 ALTER ROUTINE <em class="replaceable"><code>name</code></em> [ ( [ [ <em class="replaceable"><code>argmode</code></em> ] [ <em class="replaceable"><code>argname</code></em> ] <em class="replaceable"><code>argtype</code></em> [, ...] ] ) ]
4 <em class="replaceable"><code>action</code></em> [ ... ] [ RESTRICT ]
5 ALTER ROUTINE <em class="replaceable"><code>name</code></em> [ ( [ [ <em class="replaceable"><code>argmode</code></em> ] [ <em class="replaceable"><code>argname</code></em> ] <em class="replaceable"><code>argtype</code></em> [, ...] ] ) ]
6 RENAME TO <em class="replaceable"><code>new_name</code></em>
7 ALTER ROUTINE <em class="replaceable"><code>name</code></em> [ ( [ [ <em class="replaceable"><code>argmode</code></em> ] [ <em class="replaceable"><code>argname</code></em> ] <em class="replaceable"><code>argtype</code></em> [, ...] ] ) ]
8 OWNER TO { <em class="replaceable"><code>new_owner</code></em> | CURRENT_ROLE | CURRENT_USER | SESSION_USER }
9 ALTER ROUTINE <em class="replaceable"><code>name</code></em> [ ( [ [ <em class="replaceable"><code>argmode</code></em> ] [ <em class="replaceable"><code>argname</code></em> ] <em class="replaceable"><code>argtype</code></em> [, ...] ] ) ]
10 SET SCHEMA <em class="replaceable"><code>new_schema</code></em>
11 ALTER ROUTINE <em class="replaceable"><code>name</code></em> [ ( [ [ <em class="replaceable"><code>argmode</code></em> ] [ <em class="replaceable"><code>argname</code></em> ] <em class="replaceable"><code>argtype</code></em> [, ...] ] ) ]
12 [ NO ] DEPENDS ON EXTENSION <em class="replaceable"><code>extension_name</code></em>
14 <span class="phrase">where <em class="replaceable"><code>action</code></em> is one of:</span>
16 IMMUTABLE | STABLE | VOLATILE
18 [ EXTERNAL ] SECURITY INVOKER | [ EXTERNAL ] SECURITY DEFINER
19 PARALLEL { UNSAFE | RESTRICTED | SAFE }
20 COST <em class="replaceable"><code>execution_cost</code></em>
21 ROWS <em class="replaceable"><code>result_rows</code></em>
22 SET <em class="replaceable"><code>configuration_parameter</code></em> { TO | = } { <em class="replaceable"><code>value</code></em> | DEFAULT }
23 SET <em class="replaceable"><code>configuration_parameter</code></em> FROM CURRENT
24 RESET <em class="replaceable"><code>configuration_parameter</code></em>
26 </pre></div><div class="refsect1" id="id-1.9.3.27.5"><h2>Description</h2><p>
27 <code class="command">ALTER ROUTINE</code> changes the definition of a routine, which
28 can be an aggregate function, a normal function, or a procedure. See
29 under <a class="xref" href="sql-alteraggregate.html" title="ALTER AGGREGATE"><span class="refentrytitle">ALTER AGGREGATE</span></a>, <a class="xref" href="sql-alterfunction.html" title="ALTER FUNCTION"><span class="refentrytitle">ALTER FUNCTION</span></a>,
30 and <a class="xref" href="sql-alterprocedure.html" title="ALTER PROCEDURE"><span class="refentrytitle">ALTER PROCEDURE</span></a> for the description of the
31 parameters, more examples, and further details.
32 </p></div><div class="refsect1" id="id-1.9.3.27.6"><h2>Examples</h2><p>
33 To rename the routine <code class="literal">foo</code> for type
34 <code class="type">integer</code> to <code class="literal">foobar</code>:
35 </p><pre class="programlisting">
36 ALTER ROUTINE foo(integer) RENAME TO foobar;
38 This command will work independent of whether <code class="literal">foo</code> is an
39 aggregate, function, or procedure.
40 </p></div><div class="refsect1" id="id-1.9.3.27.7"><h2>Compatibility</h2><p>
41 This statement is partially compatible with the <code class="command">ALTER
42 ROUTINE</code> statement in the SQL standard. See
43 under <a class="xref" href="sql-alterfunction.html" title="ALTER FUNCTION"><span class="refentrytitle">ALTER FUNCTION</span></a>
44 and <a class="xref" href="sql-alterprocedure.html" title="ALTER PROCEDURE"><span class="refentrytitle">ALTER PROCEDURE</span></a> for more details. Allowing
45 routine names to refer to aggregate functions is
46 a <span class="productname">PostgreSQL</span> extension.
47 </p></div><div class="refsect1" id="id-1.9.3.27.8"><h2>See Also</h2><span class="simplelist"><a class="xref" href="sql-alteraggregate.html" title="ALTER AGGREGATE"><span class="refentrytitle">ALTER AGGREGATE</span></a>, <a class="xref" href="sql-alterfunction.html" title="ALTER FUNCTION"><span class="refentrytitle">ALTER FUNCTION</span></a>, <a class="xref" href="sql-alterprocedure.html" title="ALTER PROCEDURE"><span class="refentrytitle">ALTER PROCEDURE</span></a>, <a class="xref" href="sql-droproutine.html" title="DROP ROUTINE"><span class="refentrytitle">DROP ROUTINE</span></a></span><p>
48 Note that there is no <code class="literal">CREATE ROUTINE</code> command.
49 </p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="sql-alterrole.html" title="ALTER ROLE">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="sql-commands.html" title="SQL Commands">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="sql-alterrule.html" title="ALTER RULE">Next</a></td></tr><tr><td width="40%" align="left" valign="top">ALTER ROLE </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 18.0 Documentation">Home</a></td><td width="40%" align="right" valign="top"> ALTER RULE</td></tr></table></div></body></html>