1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
'\" t
.\" Title: ALTER ROUTINE
.\" Author: The PostgreSQL Global Development Group
.\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
.\" Date: 2024
.\" Manual: PostgreSQL 15.7 Documentation
.\" Source: PostgreSQL 15.7
.\" Language: English
.\"
.TH "ALTER ROUTINE" "7" "2024" "PostgreSQL 15.7" "PostgreSQL 15.7 Documentation"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
ALTER_ROUTINE \- change the definition of a routine
.SH "SYNOPSIS"
.sp
.nf
ALTER ROUTINE \fIname\fR [ ( [ [ \fIargmode\fR ] [ \fIargname\fR ] \fIargtype\fR [, \&.\&.\&.] ] ) ]
\fIaction\fR [ \&.\&.\&. ] [ RESTRICT ]
ALTER ROUTINE \fIname\fR [ ( [ [ \fIargmode\fR ] [ \fIargname\fR ] \fIargtype\fR [, \&.\&.\&.] ] ) ]
RENAME TO \fInew_name\fR
ALTER ROUTINE \fIname\fR [ ( [ [ \fIargmode\fR ] [ \fIargname\fR ] \fIargtype\fR [, \&.\&.\&.] ] ) ]
OWNER TO { \fInew_owner\fR | CURRENT_ROLE | CURRENT_USER | SESSION_USER }
ALTER ROUTINE \fIname\fR [ ( [ [ \fIargmode\fR ] [ \fIargname\fR ] \fIargtype\fR [, \&.\&.\&.] ] ) ]
SET SCHEMA \fInew_schema\fR
ALTER ROUTINE \fIname\fR [ ( [ [ \fIargmode\fR ] [ \fIargname\fR ] \fIargtype\fR [, \&.\&.\&.] ] ) ]
[ NO ] DEPENDS ON EXTENSION \fIextension_name\fR
where \fIaction\fR is one of:
IMMUTABLE | STABLE | VOLATILE
[ NOT ] LEAKPROOF
[ EXTERNAL ] SECURITY INVOKER | [ EXTERNAL ] SECURITY DEFINER
PARALLEL { UNSAFE | RESTRICTED | SAFE }
COST \fIexecution_cost\fR
ROWS \fIresult_rows\fR
SET \fIconfiguration_parameter\fR { TO | = } { \fIvalue\fR | DEFAULT }
SET \fIconfiguration_parameter\fR FROM CURRENT
RESET \fIconfiguration_parameter\fR
RESET ALL
.fi
.SH "DESCRIPTION"
.PP
\fBALTER ROUTINE\fR
changes the definition of a routine, which can be an aggregate function, a normal function, or a procedure\&. See under
ALTER AGGREGATE (\fBALTER_AGGREGATE\fR(7)),
ALTER FUNCTION (\fBALTER_FUNCTION\fR(7)), and
ALTER PROCEDURE (\fBALTER_PROCEDURE\fR(7))
for the description of the parameters, more examples, and further details\&.
.SH "EXAMPLES"
.PP
To rename the routine
foo
for type
integer
to
foobar:
.sp
.if n \{\
.RS 4
.\}
.nf
ALTER ROUTINE foo(integer) RENAME TO foobar;
.fi
.if n \{\
.RE
.\}
.sp
This command will work independent of whether
foo
is an aggregate, function, or procedure\&.
.SH "COMPATIBILITY"
.PP
This statement is partially compatible with the
\fBALTER ROUTINE\fR
statement in the SQL standard\&. See under
ALTER FUNCTION (\fBALTER_FUNCTION\fR(7))
and
ALTER PROCEDURE (\fBALTER_PROCEDURE\fR(7))
for more details\&. Allowing routine names to refer to aggregate functions is a
PostgreSQL
extension\&.
.SH "SEE ALSO"
ALTER AGGREGATE (\fBALTER_AGGREGATE\fR(7)), ALTER FUNCTION (\fBALTER_FUNCTION\fR(7)), ALTER PROCEDURE (\fBALTER_PROCEDURE\fR(7)), DROP ROUTINE (\fBDROP_ROUTINE\fR(7))
.PP
Note that there is no
CREATE ROUTINE
command\&.
|