ALTER PROCEDURE
ALTER PROCEDURE is used to change one or more characteristics of a stored procedure.
The syntax of ALTER PROCEDURE is as follows:
ALTER PROCEDURE proc_name [characteristic ...]
characteristic: {
COMMENT 'string'
| LANGUAGE SQL
| { CONTAINS SQL | NO SQL | READS SQL DATA | MODIFIES SQL DATA }
| SQL SECURITY { DEFINER | INVOKER }
}
The ALTER PROCEDURE statement cannot be used to change the parameters or body of a stored procedure. To make such changes, you must use DROP PROCEDURE and CREATE PROCEDURE to drop and recreate the procedure.
You must have the ALTER PROCEDURE privilege on the procedure. By default, this privilege is automatically granted to the procedure creator.
The following table describes the characteristics of routine usage of data:
-
CONTAINS SQLindicates that the routine does not contain statements that read or write data. This is the default value. For example,SET@x=1orDO RELEASE_LOCK('abc')will be executed but will not read or write data. -
NO SQLindicates that the routine does not contain SQL statements. -
READS SQL DATAindicates that the routine contains statements that read data (such asSELECT) but does not contain statements that write data. -
MODIFIES SQL DATAindicates that the routine contains statements that may write data (such asINSERTorDELETE).
SQL SECURITY can be DEFINER or INVOKER, specifying whether the routine is executed using the privileges of the specified user (who must have access to the database associated with the routine) or the privileges of the caller. The default value is DEFINER. The user calling the routine must have the EXECUTE privilege on the routine.
Here is an example of ALTER PROCEDURE:
ALTER PROCEDURE proc_name LANGUAGE SQL READS SQL DATA SQL SECURITY INVOKER COMMENT 'Example';
Query OK, 0 rows affected