Storage principle and characteristics of MySQL database?

Database stored procedures

Mysql stored procedure is a group in order to complete a specific function set of SQL statements, when compiled after the database, when the need to use the set of SQL statements stored in users only need to specify the name of the stored procedure and given parameter can be called to perform it in a nutshell is a set of commands already written, you need the time out with it.

A, Mysql stored procedure Introduction:

Storage process is a programmable function that created and saved in the database. It may have some special SQL statements and control structures. When it is desired to perform the same function in different applications or internet, or a package with a particular function, the storage process is very useful. Database stored procedure can be seen as an object-oriented programming in the simulation method. It allows controlled access to data. Stored procedure typically has the following advantages:

The stored procedure can achieve faster execution speed.

If an operation contains a large number of Transaction-SQL code or are executed multiple times, then the stored procedure execution speed much faster than the batch. Because stored procedures are precompiled. When you first run a stored procedure query optimizer analyze optimization, and gives the final execution plan is stored in the system tables. The batch Transaction-SQL statements should be compiled and optimized for each run, the speed is relatively slow.
Experience: compiler optimization, fast!

Stored programming procedure allows standard components.

After the stored procedure is created, it can be called multiple times in the program without having to re-write the SQL statements stored procedure. And database professionals can be modified at any time of the stored procedure, there is no impact on the application source code.
Experience: encapsulation and abstraction, a simple call

Flow control process can be stored prepared statements, a lot of flexibility, and can perform complex judgment operation more complex.

Experience: powerful, powerful logic

Stored procedures can be used as a security mechanism to take advantage of.

The system administrator to restrict permissions by executing a stored procedure can be achieved corresponding restrictions on access to data, avoid unauthorized user access to data, ensuring data security.
Experience: restrictions and security

Stored procedures can reduce network traffic too.

For operation with a database object (such as query, modify), if the operation involved Transaction-SQL statements stored procedure is organized process, then when you call the stored procedure on the client computer, the network delivered just the call statement, thereby greatly increasing the network traffic and reduces network load.

Published 19 original articles · won praise 10 · views 2465

Guess you like

Origin blog.csdn.net/qq_40125653/article/details/88749352