Home > Database > Mysql Tutorial > body text

What does MySQL stored procedure mean?

青灯夜游
Release: 2019-05-23 18:56:29
Original
3371 people have browsed it

What does MySQL stored procedure mean?

Stored Procedure (Stored Procedure) is a database object that stores complex programs in the database so that they can be called by external programs; it is a set of SQL statements designed to complete specific functions. After being compiled and stored in the database, the user calls and executes it by specifying the name of the stored procedure and giving parameters (if the stored procedure has parameters).

A stored procedure is a programmable function that is created and saved in the database. It can consist of SQL statements and some special control structures. Stored procedures are useful when you want to perform the same function on different applications or platforms, or encapsulate specific functionality. Stored procedures in a database can be seen as a simulation of the object-oriented approach in programming. It allows control over how data is accessed.

The concept of stored procedures is very simple, it is code encapsulation and reuse at the SQL language level of the database; it is supported starting from MySQL version 5.0.

Advantages and disadvantages of stored procedures:

1. Advantages

● Stored procedures enhance the functionality and flexibility of the SQL language. Stored procedures can be written using flow control statements, are highly flexible, and can complete complex judgments and more complex operations.

● Stored procedures allow standard components to be programmed. After a stored procedure is created, it can be called multiple times in the program without having to rewrite the SQL statement of the stored procedure. And database professionals can modify stored procedures at any time without affecting the application source code.

● Stored procedures can achieve faster execution speed. If an operation contains a large amount of Transaction-SQL code or is executed multiple times, the stored procedure will execute much faster than batch processing. Because stored procedures are precompiled. When a stored procedure is run for the first time, the query is analyzed and optimized by the optimizer and an execution plan is finally stored in the system table. The batch Transaction-SQL statement must be compiled and optimized every time it is run, and the speed is relatively slower.

● Stored procedures can reduce network traffic. For operations on the same database object (such as query, modification), if the Transaction-SQL statement involved in this operation is organized into a stored procedure, then when the stored procedure is called on the client computer, only the call is transmitted over the network statements, thereby greatly increasing network traffic and reducing network load.

● Stored procedures can be fully utilized as a security mechanism. By restricting the permissions for executing a certain stored procedure, the system administrator can limit the access permissions of the corresponding data, avoid unauthorized users from accessing the data, and ensure the security of the data.

2. Disadvantages

● Stored procedures are often customized for specific databases because the supported programming languages ​​are different. When switching to a database system from another manufacturer, the original stored procedures need to be rewritten.

● Performance tuning and writing of stored procedures are limited by various database systems.

The above is the detailed content of What does MySQL stored procedure mean?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template