MYSQL stored procedure One--basic syntax and parameters introduction

Source: Internet
Author: User

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:
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:
Call procedure_name (parameter list);
    • Delete:
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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.