The ALTER PROCEDURE statement modifies a stored procedure.
Required privileges
Refer to the respective subcommands.
Synopsis
Parameters
| Parameter | Description | 
|---|---|
proc_name | 
The name of the procedure to alter. | 
routine_param | 
An optional list of procedure parameters. | 
Subcommands
| Subcommand | Description | 
|---|---|
OWNER TO | 
Change the owner of a procedure. | 
RENAME TO | 
Change the name of a procedure. | 
SET SCHEMA | 
Change the schema of a procedure. | 
OWNER TO
ALTER PROCEDURE ... OWNER TO is used to change the owner of a procedure.
Required privileges
- To alter the owner of a procedure, the new owner must have 
CREATEprivilege on the schema of the procedure. - To alter a procedure, a user must own the procedure.
 - To alter a procedure, a user must have 
DROPprivilege on the schema of the procedure. 
Parameters
| Parameter | Description | 
|---|---|
role_spec | 
The role to set as the owner of the procedure. | 
See Synopsis.
RENAME TO
ALTER PROCEDURE ... RENAME TO changes the name of a procedure.
Required privileges
- To alter a procedure, a user must own the procedure.
 - To alter a procedure, a user must have 
DROPprivilege on the schema of the procedure. 
Parameters
| Parameter | Description | 
|---|---|
proc_new_name | 
The new name of the procedure. | 
See Synopsis.
SET SCHEMA
ALTER PROCEDURE ... SET SCHEMA changes the schema of a procedure.
CockroachDB supports SET SCHEMA as an alias for setting the search_path session variable.
Required privileges
- To change the schema of a procedure, a user must have 
CREATEprivilege on the new schema. - To alter a procedure, a user must own the procedure.
 - To alter a procedure, a user must have 
DROPprivilege on the schema of the procedure. 
Parameters
| Parameter | Description | 
|---|---|
schema_name | 
The name of the new schema for the procedure. | 
See Synopsis.
Examples
Rename a stored procedure
The following statement renames the delete_earliest_histories example procedure to delete_histories:
ALTER PROCEDURE delete_earliest_histories RENAME TO delete_histories;