Stored procedures and the role of the advantages and disadvantages

First, what is stored procedure:
stored procedures
in a large database system, in order to complete a set of specific functions set of SQL statements, stored in a database, compiled after the first call does not need to re-compile again,
the user specified by the stored procedure parameter name given to execute it (if the stored procedure with parameters). A stored procedure is an important object in the database, any well-designed database applications should use stored procedures.
Second, why use stored procedures do?
Stored procedures really so important to you that in the end what good is it? Stored procedures that white is a bunch of SQL merger. The middle of the logic control point.
1. The process is useful when dealing with stored complex operations. Specifically divided into two areas:
on (a) the response time it has
advantages: if you deal in the foreground words. It may involve multiple database connections. But if you use a stored procedure, then it only once. Stored procedures can bring benefits to our operational efficiency;
(b), using the system stored procedure from a more stable security: Program BUG prone to instability, and stored procedures, no problems as long as the database is basically not what problems will arise.
2. A small amount of data items stored procedures may not be working properly.
Third, when you only need to use stored procedures?
Stored procedures are not just for large projects for small and medium sized projects, using stored procedures is also very necessary.
Its main advantage:
1. Stored procedure only when creating compiled, each subsequent implementation of the storage process is not need to recompile the general SQL statement is executed once every time it is compiled using stored procedures can improve database speed of execution.
2. When complex database operations (such as multiple tables Update, Insert, Query, when Delete) stored can be encapsulated by this procedure with a binding complex operations and transactions provided by the database.
These operations, if the procedure is done, it becomes a section of the SQL statement, you may want to connect to the database several times. And into storage, only you need to connect to a database on it.
3. Storage process can be repeated use
can reduce the workload of database developers.
4. The safety
can be set only for a user having a right to use the specified storage procedure.
The better adaptability: Since the storage process of the database access is performed by storing procedure, the database developer
can change the database without any changes to the stored procedure interface,
and these changes will not apply Cheng
sequence affected.
6. Distributed Work: coding applications and databases can be performed independently, without pressing another.
In general, writing stored procedures than basic
SQL
complex statements, writing stored procedures require higher skills and more
experience.
Fourth, the strengths and weaknesses of the system development process used to store
the following advantages:
1. High efficiency.
2. Good safety performance.
3. For some applications very easy to implement demand.

The following disadvantages:
1. The relatively poor maintainability.
2. readability is poor.

Published 62 original articles · won praise 39 · views 120 000 +

Guess you like

Origin blog.csdn.net/liangjiabao5555/article/details/96700379