2 .\" Title: ALTER PROCEDURE
3 .\" Author: The PostgreSQL Global Development Group
4 .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
6 .\" Manual: PostgreSQL 18.0 Documentation
7 .\" Source: PostgreSQL 18.0
10 .TH "ALTER PROCEDURE" "7" "2025" "PostgreSQL 18.0" "PostgreSQL 18.0 Documentation"
11 .\" -----------------------------------------------------------------
12 .\" * Define some portability stuff
13 .\" -----------------------------------------------------------------
14 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 .\" http://bugs.debian.org/507673
16 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
25 .\" disable justification (adjust text to left margin only)
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
31 ALTER_PROCEDURE \- change the definition of a procedure
35 ALTER PROCEDURE \fIname\fR [ ( [ [ \fIargmode\fR ] [ \fIargname\fR ] \fIargtype\fR [, \&.\&.\&.] ] ) ]
36 \fIaction\fR [ \&.\&.\&. ] [ RESTRICT ]
37 ALTER PROCEDURE \fIname\fR [ ( [ [ \fIargmode\fR ] [ \fIargname\fR ] \fIargtype\fR [, \&.\&.\&.] ] ) ]
38 RENAME TO \fInew_name\fR
39 ALTER PROCEDURE \fIname\fR [ ( [ [ \fIargmode\fR ] [ \fIargname\fR ] \fIargtype\fR [, \&.\&.\&.] ] ) ]
40 OWNER TO { \fInew_owner\fR | CURRENT_ROLE | CURRENT_USER | SESSION_USER }
41 ALTER PROCEDURE \fIname\fR [ ( [ [ \fIargmode\fR ] [ \fIargname\fR ] \fIargtype\fR [, \&.\&.\&.] ] ) ]
42 SET SCHEMA \fInew_schema\fR
43 ALTER PROCEDURE \fIname\fR [ ( [ [ \fIargmode\fR ] [ \fIargname\fR ] \fIargtype\fR [, \&.\&.\&.] ] ) ]
44 [ NO ] DEPENDS ON EXTENSION \fIextension_name\fR
46 where \fIaction\fR is one of:
48 [ EXTERNAL ] SECURITY INVOKER | [ EXTERNAL ] SECURITY DEFINER
49 SET \fIconfiguration_parameter\fR { TO | = } { \fIvalue\fR | DEFAULT }
50 SET \fIconfiguration_parameter\fR FROM CURRENT
51 RESET \fIconfiguration_parameter\fR
57 changes the definition of a procedure\&.
59 You must own the procedure to use
60 \fBALTER PROCEDURE\fR\&. To change a procedure\*(Aqs schema, you must also have
62 privilege on the new schema\&. To alter the owner, you must be able to
64 to the new owning role, and that role must have
66 privilege on the procedure\*(Aqs schema\&. (These restrictions enforce that altering the owner doesn\*(Aqt do anything you couldn\*(Aqt do by dropping and recreating the procedure\&. However, a superuser can alter ownership of any procedure anyway\&.)
71 The name (optionally schema\-qualified) of an existing procedure\&. If no argument list is specified, the name must be unique in its schema\&.
76 The mode of an argument:
80 VARIADIC\&. If omitted, the default is
86 The name of an argument\&. Note that
88 does not actually pay any attention to argument names, since only the argument data types are used to determine the procedure\*(Aqs identity\&.
93 The data type(s) of the procedure\*(Aqs arguments (optionally schema\-qualified), if any\&. See
94 DROP PROCEDURE (\fBDROP_PROCEDURE\fR(7))
95 for the details of how the procedure is looked up using the argument data type(s)\&.
100 The new name of the procedure\&.
105 The new owner of the procedure\&. Note that if the procedure is marked
106 SECURITY DEFINER, it will subsequently execute as the new owner\&.
111 The new schema for the procedure\&.
116 This form marks the procedure as dependent on the extension, or no longer dependent on the extension if
118 is specified\&. A procedure that\*(Aqs marked as dependent on an extension is dropped when the extension is dropped, even if cascade is not specified\&. A procedure can depend upon multiple extensions, and will be dropped when any one of those extensions is dropped\&.
121 [ EXTERNAL ] SECURITY INVOKER
123 [ EXTERNAL ] SECURITY DEFINER
125 Change whether the procedure is a security definer or not\&. The key word
127 is ignored for SQL conformance\&. See
128 CREATE PROCEDURE (\fBCREATE_PROCEDURE\fR(7))
129 for more information about this capability\&.
132 \fIconfiguration_parameter\fR
136 Add or change the assignment to be made to a configuration parameter when the procedure is called\&. If
142 is used, the procedure\-local setting is removed, so that the procedure executes with the value present in its environment\&. Use
144 to clear all procedure\-local settings\&.
146 saves the value of the parameter that is current when
147 \fBALTER PROCEDURE\fR
148 is executed as the value to be applied when the procedure is entered\&.
154 for more information about allowed parameter names and values\&.
159 Ignored for conformance with the SQL standard\&.
163 To rename the procedure
165 with two arguments of type
174 ALTER PROCEDURE insert_data(integer, integer) RENAME TO insert_record;
180 To change the owner of the procedure
182 with two arguments of type
191 ALTER PROCEDURE insert_data(integer, integer) OWNER TO joe;
197 To change the schema of the procedure
199 with two arguments of type
208 ALTER PROCEDURE insert_data(integer, integer) SET SCHEMA accounting;
214 To mark the procedure
215 insert_data(integer, integer)
216 as being dependent on the extension
223 ALTER PROCEDURE insert_data(integer, integer) DEPENDS ON EXTENSION myext;
229 To adjust the search path that is automatically set for a procedure:
235 ALTER PROCEDURE check_password(text) SET search_path = admin, pg_temp;
241 To disable automatic setting of
249 ALTER PROCEDURE check_password(text) RESET search_path;
255 The procedure will now execute with whatever search path is used by its caller\&.
258 This statement is partially compatible with the
259 \fBALTER PROCEDURE\fR
260 statement in the SQL standard\&. The standard allows more properties of a procedure to be modified, but does not provide the ability to rename a procedure, make a procedure a security definer, attach configuration parameter values to a procedure, or change the owner, schema, or volatility of a procedure\&. The standard also requires the
262 key word, which is optional in
265 CREATE PROCEDURE (\fBCREATE_PROCEDURE\fR(7)), DROP PROCEDURE (\fBDROP_PROCEDURE\fR(7)), ALTER FUNCTION (\fBALTER_FUNCTION\fR(7)), ALTER ROUTINE (\fBALTER_ROUTINE\fR(7))