table of contents
ALTER PROCEDURE(7) | PostgreSQL 16.1 Documentation | ALTER PROCEDURE(7) |
NAME¶
ALTER_PROCEDURE - change the definition of a procedure
SYNOPSIS¶
ALTER PROCEDURE name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ]
action [ ... ] [ RESTRICT ] ALTER PROCEDURE name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ]
RENAME TO new_name ALTER PROCEDURE name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ]
OWNER TO { new_owner | CURRENT_ROLE | CURRENT_USER | SESSION_USER } ALTER PROCEDURE name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ]
SET SCHEMA new_schema ALTER PROCEDURE name [ ( [ [ argmode ] [ argname ] argtype [, ...] ] ) ]
[ NO ] DEPENDS ON EXTENSION extension_name where action is one of:
[ EXTERNAL ] SECURITY INVOKER | [ EXTERNAL ] SECURITY DEFINER
SET configuration_parameter { TO | = } { value | DEFAULT }
SET configuration_parameter FROM CURRENT
RESET configuration_parameter
RESET ALL
DESCRIPTION¶
ALTER PROCEDURE changes the definition of a procedure.
You must own the procedure to use ALTER PROCEDURE. To change a procedure's schema, you must also have CREATE privilege on the new schema. To alter the owner, you must be able to SET ROLE to the new owning role, and that role must have CREATE privilege on the procedure's schema. (These restrictions enforce that altering the owner doesn't do anything you couldn't do by dropping and recreating the procedure. However, a superuser can alter ownership of any procedure anyway.)
PARAMETERS¶
name
argmode
argname
argtype
new_name
new_owner
new_schema
extension_name
[ EXTERNAL ] SECURITY INVOKER
[ EXTERNAL ] SECURITY DEFINER
configuration_parameter
value
See SET(7) and Chapter 20 for more information about allowed parameter names and values.
RESTRICT
EXAMPLES¶
To rename the procedure insert_data with two arguments of type integer to insert_record:
ALTER PROCEDURE insert_data(integer, integer) RENAME TO insert_record;
To change the owner of the procedure insert_data with two arguments of type integer to joe:
ALTER PROCEDURE insert_data(integer, integer) OWNER TO joe;
To change the schema of the procedure insert_data with two arguments of type integer to accounting:
ALTER PROCEDURE insert_data(integer, integer) SET SCHEMA accounting;
To mark the procedure insert_data(integer, integer) as being dependent on the extension myext:
ALTER PROCEDURE insert_data(integer, integer) DEPENDS ON EXTENSION myext;
To adjust the search path that is automatically set for a procedure:
ALTER PROCEDURE check_password(text) SET search_path = admin, pg_temp;
To disable automatic setting of search_path for a procedure:
ALTER PROCEDURE check_password(text) RESET search_path;
The procedure will now execute with whatever search path is used by its caller.
COMPATIBILITY¶
This statement is partially compatible with the ALTER PROCEDURE 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 RESTRICT key word, which is optional in PostgreSQL.
SEE ALSO¶
CREATE PROCEDURE (CREATE_PROCEDURE(7)), DROP PROCEDURE (DROP_PROCEDURE(7)), ALTER FUNCTION (ALTER_FUNCTION(7)), ALTER ROUTINE (ALTER_ROUTINE(7))
2023 | PostgreSQL 16.1 |