1<!--
2doc/src/sgml/ref/alter_routine.sgml
3PostgreSQL documentation
4-->
5
6<refentry id="sql-alterroutine">
7 <indexterm zone="sql-alterroutine">
8  <primary>ALTER ROUTINE</primary>
9 </indexterm>
10
11 <refmeta>
12  <refentrytitle>ALTER ROUTINE</refentrytitle>
13  <manvolnum>7</manvolnum>
14  <refmiscinfo>SQL - Language Statements</refmiscinfo>
15 </refmeta>
16
17 <refnamediv>
18  <refname>ALTER ROUTINE</refname>
19  <refpurpose>change the definition of a routine</refpurpose>
20 </refnamediv>
21
22 <refsynopsisdiv>
23<synopsis>
24ALTER ROUTINE <replaceable>name</replaceable> [ ( [ [ <replaceable class="parameter">argmode</replaceable> ] [ <replaceable class="parameter">argname</replaceable> ] <replaceable class="parameter">argtype</replaceable> [, ...] ] ) ]
25    <replaceable class="parameter">action</replaceable> [ ... ] [ RESTRICT ]
26ALTER ROUTINE <replaceable>name</replaceable> [ ( [ [ <replaceable class="parameter">argmode</replaceable> ] [ <replaceable class="parameter">argname</replaceable> ] <replaceable class="parameter">argtype</replaceable> [, ...] ] ) ]
27    RENAME TO <replaceable>new_name</replaceable>
28ALTER ROUTINE <replaceable>name</replaceable> [ ( [ [ <replaceable class="parameter">argmode</replaceable> ] [ <replaceable class="parameter">argname</replaceable> ] <replaceable class="parameter">argtype</replaceable> [, ...] ] ) ]
29    OWNER TO { <replaceable>new_owner</replaceable> | CURRENT_USER | SESSION_USER }
30ALTER ROUTINE <replaceable>name</replaceable> [ ( [ [ <replaceable class="parameter">argmode</replaceable> ] [ <replaceable class="parameter">argname</replaceable> ] <replaceable class="parameter">argtype</replaceable> [, ...] ] ) ]
31    SET SCHEMA <replaceable>new_schema</replaceable>
32ALTER ROUTINE <replaceable>name</replaceable> [ ( [ [ <replaceable class="parameter">argmode</replaceable> ] [ <replaceable class="parameter">argname</replaceable> ] <replaceable class="parameter">argtype</replaceable> [, ...] ] ) ]
33    [ NO ] DEPENDS ON EXTENSION <replaceable>extension_name</replaceable>
34
35<phrase>where <replaceable class="parameter">action</replaceable> is one of:</phrase>
36
37    IMMUTABLE | STABLE | VOLATILE
38    [ NOT ] LEAKPROOF
39    [ EXTERNAL ] SECURITY INVOKER | [ EXTERNAL ] SECURITY DEFINER
40    PARALLEL { UNSAFE | RESTRICTED | SAFE }
41    COST <replaceable class="parameter">execution_cost</replaceable>
42    ROWS <replaceable class="parameter">result_rows</replaceable>
43    SET <replaceable class="parameter">configuration_parameter</replaceable> { TO | = } { <replaceable class="parameter">value</replaceable> | DEFAULT }
44    SET <replaceable class="parameter">configuration_parameter</replaceable> FROM CURRENT
45    RESET <replaceable class="parameter">configuration_parameter</replaceable>
46    RESET ALL
47</synopsis>
48 </refsynopsisdiv>
49
50 <refsect1>
51  <title>Description</title>
52
53  <para>
54   <command>ALTER ROUTINE</command> changes the definition of a routine, which
55   can be an aggregate function, a normal function, or a procedure.  See
56   under <xref linkend="sql-alteraggregate"/>, <xref linkend="sql-alterfunction"/>,
57   and <xref linkend="sql-alterprocedure"/> for the description of the
58   parameters, more examples, and further details.
59  </para>
60 </refsect1>
61
62 <refsect1>
63  <title>Examples</title>
64
65  <para>
66   To rename the routine <literal>foo</literal> for type
67   <type>integer</type> to <literal>foobar</literal>:
68<programlisting>
69ALTER ROUTINE foo(integer) RENAME TO foobar;
70</programlisting>
71   This command will work independent of whether <literal>foo</literal> is an
72   aggregate, function, or procedure.
73  </para>
74 </refsect1>
75
76 <refsect1>
77  <title>Compatibility</title>
78
79  <para>
80   This statement is partially compatible with the <command>ALTER
81   ROUTINE</command> statement in the SQL standard.  See
82   under <xref linkend="sql-alterfunction"/>
83   and <xref linkend="sql-alterprocedure"/> for more details.  Allowing
84   routine names to refer to aggregate functions is
85   a <productname>PostgreSQL</productname> extension.
86  </para>
87 </refsect1>
88
89 <refsect1>
90  <title>See Also</title>
91
92  <simplelist type="inline">
93   <member><xref linkend="sql-alteraggregate"/></member>
94   <member><xref linkend="sql-alterfunction"/></member>
95   <member><xref linkend="sql-alterprocedure"/></member>
96   <member><xref linkend="sql-droproutine"/></member>
97  </simplelist>
98
99  <para>
100   Note that there is no <literal>CREATE ROUTINE</literal> command.
101  </para>
102 </refsect1>
103</refentry>
104