Why use stored procedures

□ by the encapsulation process in an easy to use unit, you can simplify a complicated operation.

□ by not requiring repeated establish a series of processing steps, thus ensuring data consistency. If all developers and applications use the same stored procedure code is used it is the same. This extension is to prevent errors. The more steps need to be performed, the greater the possibility of error. Prevent errors to ensure data consistency.

□ simplify the management of change. If the table name, column name or business logic (or other content) have changed, then only need to change the stored procedure code. Use it do not need to even know these changes. This extension is security. Restrict stored procedure access to the underlying data, reducing data corruption (unintentional or other reasons caused data corruption) opportunities.

□ Because stored procedures are usually stored in a compiled form, so the DBMS handle less work required commands to improve performance.

□ some can only be used in a single SQL request elements and attributes, stored procedures can use to write code more powerful and more flexible. In other words, use the stored procedure has three major advantages, namely simple, safe and high performance. Obviously, they are important. However, before converting SQL stored procedure code, you must also know some of its flaws.

□ stored procedure syntax is different in different DBMS. In fact, writing truly portable storage process is almost impossible. However, the stored procedure calls itself (name and how data transfer) can remain relatively portable. Therefore, if the need to migrate to other DBMS, at least client application code does not need to change.

□ In general, writing stored procedures complicated than writing basic SQL statements require higher skills and more experience. Therefore, many database administrators to create stored procedures limit as a safety measure (the impact on mainly by a defect).

Published 47 original articles · won praise 6 · views 5077

Guess you like

Origin blog.csdn.net/qq_22583191/article/details/104366025