A stored procedure is a set of SQL statements to complete a particular function, and after the first compilation, the call is no longer compiled
CREATE PROCEDURE procedure_name ([parameter list]) [characteristic ...]
Beginroutine_body
End
which
Procedure_name: Name of the stored procedure;
Parameter list: A parameter list that can contain 0 or more parameters, separated by a comma (,) between the parameters.
The form of each parameter is: parameter type parameter name data type
Parameter type: in (input parameter) out (output parameter) inout (input and output parameters, specified when invoked, can be modified and returned)
Characteristic: This option, which represents the stored procedure attribute, has the following values:
1) Language sql: Stored procedure consists of SQL statements, SQL is the unique value of the language feature;
2) [NOT] deterministic: Indicates whether the result is a determined value, that is, the same input must be able to obtain the same output, the default is not deterministic;
3) contains SQL (the stored procedure contains SQL statements, but does not contain read-write data statements) | No SQL (stored procedure does not contain SQL statements) | Reads SQL data (the statement that the stored procedure contains read data) |modifies SQL data (the stored procedure contains statements that read and write data)
4) SQL Security {Definer (only the defined person can execute the stored procedure) |invoker (the caller with permission can execute)}, default Definer
5) Comment ' string ' (note, description stored procedure)
Routine_body: Program body.
Call procedure_name (parameter list);
drop procedure procedure_name;
Ps:
1. Before creating a stored procedure, specify the database to which the stored procedure belongs;
2. Query the stored procedures contained in a database (set the database name to factory, including a stored procedure named Sum_app):
3. Query stored procedure creation statement:
4. You can call another stored procedure in one stored procedure, but you cannot delete another stored procedure.
MYSQL stored procedure One--basic syntax and parameters introduction