Thursday, August 27, 2009

[Level 2] MySQL Stored Procedure Characteristics

MySQL Stored Procedure has two major characters, "SQL SECURITY" and "Data Use".
"SQL SECURITY" defines what's the effect user while procedure is called, and "Data Use" indicates the procedure R/W. The detail information as the following:
1. SQL SECURITY:
  a. DEFINER-The routine will have the privileges of the user who created it.
  b. INVOKER-The routine will have the privileges of ther user who run it.
  If you want to change the character, use the command as below:
  mysql> ALTER PROCEDURE procedure_name SQL SECURITY [DEFINER/INVOKER];
2. Data Use:
  a. CONTAONS SQL-The option indicates that the routine has the SQL statement but it does not have read or write data.
  b. NO SQL-The option indicates that the routine does not have SQL statement.
  c. READS SQL DATA-The option indicates that the routine has the SQL statement with read data only.
  d. MODIFIES SQL DATA-The option indicates that the routine has the SQL statement with modify data.
  If you want to change the character, use the command as below:
  mysql> ALTER PROCEDURE procedure_name [CONTAINS SQL/NO SQL/READS SQL DATA/MODIFIES SQL DATA];

Wish this helps.

regards,
Stanley Huang