Stored Procedures and functions

Source: Internet
Author: User

Stored procedures and functions are a collection of SQL statements that have been compiled and stored in a database, and calling stored procedures and functions can simplify the workload of the developer and reduce the data transfer between the database and the application server, which is good for improving data processing efficiency. The difference between a stored procedure and a function is that the function must have a return value, and the stored procedure does not; The stored procedure can use in, out, and inout types, while the parameters of the function can only use the in type.

Create, modify, delete stored procedures or functions

the syntax for calling a stored procedure is as follows:

MySQL stored procedures and functions allow for commit and rollback, but do not allow the load data infile statement to execute. Create an instance of the stored procedure as follows:

The invocation of a stored procedure is the same as the ability to execute SQL directly, but the benefit of the stored procedure is that the logic is split on the database side, the caller does not need to know the logic, and once the processing logic changes, only the stored procedure needs to be modified.

Characteristic is described below:

    • LANGUAGE sql: The following procedure is written using the SQL language, system default.
    • [NOT] Deterministic:deterministic determines that the output is the same for each input. [NOT] Deterministic: non-deterministic.
    • {CONTAINS Sql|no sql| READS SQL data| Modifies SQL Data}:contains sql: A statement that indicates that the subroutine does not contain read-write data; No SQL: Indicates that the subroutine does not contain SQL statements; READS SQL data: A statement that represents a subroutine that contains read data; modifies SQL Data: Represents the statement that the subroutine contains write data. The default is contains SQL.
    • sqlsecurity{definer| INVOKER}: Used to specify whether the subroutine should be executed using the license to create the subroutine, or by using the caller's permission. The default is Definer.
    • COMMENT ' stirng ': A comment that stores a procedure or function.

specific syntax for deleting stored procedures and functions :

Stored Procedures and functions

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.