MySQL stored procedure is very verbose, compared to MSSQL or Oracle stored procedures, if not explicitly specified, he implicitly specifies a series of attributes (characteristic) default values to create a stored procedure
Typically, when you use the graphical interface tool to write stored procedures, the graphical interface tool automatically adds this content, such as when creating stored procedures with Heidisql, and automatically generates the default values for these attributes (characteristic).
But what is the nature of these features, what effect, has not been how to find out.
LANGUAGE SQL
The stored procedure language, which defaults to SQL, describes the SQL language used in the stored procedure, temporarily supports only SQL, and may later support other languages
Not deterministic
Deterministic input is deterministic output, default is not deterministic, only for the same input, the output is the same, the current value has not been used
CONTAINS SQL
Provides intrinsic information about the use of data by subroutines, which are currently available to the server and do not constrain the actual use of the data based on these eigenvalues, which is not used
Includes the following four options
1.CONTAINS SQL indicates that a subroutine does not contain read or write data statements
2.NO SQL indicates that the subroutine does not contain SQL
3.READS SQL data indicates that a subroutine contains a statement that reads data, but does not contain a statement that writes data
4.MODIFIES SQL data indicates that the subroutine contains statements that write data.
SQL SECURITY Definer
Used to specify whether the stored procedure is executed using the creator's license or by the performer's license, the default value is Definer
Definer the identity of the creator to invoke, for the current user: If the permissions of the stored procedure are executed and the creator has permission to access the table, the current user can execute the call of the procedure successfully.
To be blunt, the current user invokes the stored procedure, and the specific operation performed by the stored procedure is performed with the permission of the user who defined the stored procedure.
INVOKER the caller's identity to execute, for the current user: If you execute the permissions of the stored procedure to access the table as the current identity, if the current identity does not have access to the table, even if there is permission to execute the procedure, it is still not possible to successfully execute the call of the procedure.
To be blunt, the current user invokes a stored procedure that executes only if the current user has permission to perform the operation of the object designed in the stored procedure.
COMMENT "
The annotated information of the stored procedure is written in comment, where it can only be a single line of text, and multiple lines will be removed to a carriage return, a word: pull
Why do you say this nonsense?
Usually, the landlord will comment on a call to the stored procedure example in the notes, in order to avoid the others in the debugging, the parameters of a lot of time, call up, trouble to write a half-day parameters and so on
--so there will be comments like the following, but the statements in the comments are all saved in one line, and the format is erased.
/*
Set @p_parameter1 = ' abc ';
Set @p_parameter2 = 200;
Call Mysql_procedure (@p_parameyter1, @p_parameter2)
*/
The following is a demo,delimiter of a stored procedure just to let the stored procedure know that it is the end tag when encountering a delimiter defined character.
In other words, MySQL does not support anonymous block even if the definition of the stored procedure, when the end of his own can not parse it?
delimiter kkkkkkkkCREATEDefiner=' Root ' @ '%`PROCEDURE' Porcedurename ' (inchP_parameter1varchar( $),inchP_parameter2int, Out P_outparameterint) --The stored procedure language, which defaults to SQL, describes the SQL language used in the stored procedure, temporarily supports only SQL, and may later support other languagesLANGUAGE SQL--deterministic input is deterministic output, default is not deterministic, only for the same input, the output is the same, the current value has not been used notDeterministic--provides intrinsic information about the use of data by subroutines, which are currently available to the server and do not constrain the actual use of the data based on these eigenvalues, which is not used --Ontains SQL indicates that a subroutine does not contain read or write data statements --No SQL indicates that the subroutine does not contain SQL --READS SQL Data indicates that a subroutine contains a statement that reads data, but does not contain a statement that writes data --modifies SQL data indicates that a subroutine contains write-Data statements CONTAINSSQL--used to specify whether the stored procedure is executed using the creator's license or by the performer's license, the default value is Definer --Definer is called by the Creator, and if the creator has permission to access the table in the stored procedure, the caller has permission to execute the procedure. --INVOKER The caller's identity to execute, depending on whether the call has Execute procedure + permissions for SQL statements during executionSQL SECURITY Definer--The annotated information of the stored procedure is written in comment, where it can only be a single line of text, and multiple lines will be removed to a carriage return, a word: Pull --Why do you say this nonsense? --Usually, the landlord will comment on a call to the stored procedure example in the notes, in order to avoid the others in the debugging, the parameters of a lot of time, call up, trouble to write a half-day parameters and so on --so there will be comments like the following, but the statements in the comments are all saved in one line, and the format is erased. /*Set @p_parameter1 = ' abc '; Set @p_parameter2 = 200; Call Mysql_procedure (@p_parameyter1, @p_parameter2)*/COMMENT"'begin Select * from User whereId= -; EndKKKKKKKK
Reference: "In layman's MySQL"
Meaning of the attributes (characteristic) in the MySQL stored procedure definition