ALTER PROCEDURE statement¶
The ALTER PROCEDURE statement modifies a user-defined procedure (UDP) in the used schema, including its name and comment.
To alter the input parameters accepted by a UDP without changing the name or procedure body, drop the UDP and create a new one.
To alter the procedure body without changing the name or input parameters, use CREATE OR REPLACE PROCEDURE.
Note
An operation involving a non-default schema or an object in it requires access to the schema, either implicitly or through an explicit USAGE grant, as well as the privilege required for the operation. The schema access check and the privilege check for the requested operation are independent; satisfying one does not satisfy the other. Schema access control does not apply to temporary graphs or built-in procedures and functions. For more information, see Schema access control.
Prerequisites¶
- The UDP is created. For more information, see CREATE PROCEDURE.
- To alter a UDP, you must either be the owner of the UDP, be granted to perform the action
ALTERon the UDP, or be granted to perform the actionALTER ANY PROCEDUREon the used schema. For more information, see Roles and privileges.
Syntax¶
- alter_procedure_statement
- parameter_declaration
alter_procedure_statement ::=
'ALTER' 'PROCEDURE' procedure_name '(' ( parameter_declaration ( ',' parameter_declaration )* )? ')'
( ('COMMENT' new_comment_string) |
('RENAME' 'TO' new_procedure_name) )
parameter_declaration ::=
parameter_name? parameter_type ('DEFAULT' default_value )?
Parameters¶
procedure_name¶
The name of the UDP to be altered.
parameter_name¶
The name of the input parameter accepted by the UDP.
parameter_type¶
The data type of the input parameter accepted by the UDP.
default_value¶
The default value of the input parameter.
new_comment_string¶
The new description of the UDP.
new_procedure_name¶
The new name of the UDP to be altered.
procedure_name must be an identifier. For more information about identifiers, see Rules for naming identifiers.
Examples¶
Alter the comment of a UDP¶
'''
// Create UDP `test1`
CREATE OR REPLACE PROCEDURE test4(a INT, b STRING) RETURNS (x INT, y STRING) COMMENT 'test_comment_1' AS { RETURN a, b }
'''
'''
ALTER PROCEDURE test4(INT, STRING) COMMENT 'test_comment_2'
'''
Alter the name of a UDP¶
ALTER PROCEDURE test4(INT, STRING) RENAME TO test44