MySql stored procedure-1. basic knowledge of SQL Stored Procedure-MySQL-mysql tutorial

Source: Internet
Author: User
Tags mysql tutorial
MySql stored procedure-1. basic knowledge of SQL Stored procedure bitsCN.com
MySql stored procedure-1. basic knowledge of SQL Stored procedure before understanding MySq, let's take a look at some simple questions.
Q: What is a stored procedure? (Stored procedure) A: It is A piece of written SQL code, especially it exists in the Database Directory. Therefore, external programs can directly call the stored procedure defined in the database. In addition, triggers in the database or other stored procedures can also call the stored procedure. Q: What are the advantages of stored procedures? What are the disadvantages? A: Let's take A look at the advantages: 1. First, the performance is improved, compared to sending SQL statements to the database through applications, make the database execute the stored procedure more efficient and faster (the stored procedure compiles the SQL statement and stores it in the Database Directory ); 2. stored procedures also reduce the frequency of information interaction between applications and the server. it can be imagined that, instead of using stored procedures, the application needs to send multiple SQL commands to the server, to use a stored procedure, you only need to call the stored procedure statement and obtain the required data. 3. the storage process is highly reusable and transparent. it can be used by any application because it is stored in the database. The new application only needs to call the corresponding stored procedure to obtain the corresponding data service. 4. stored procedures are also a secure approach. database administrators can use the stored procedures to obtain data services for applications that do not have the permission to access tables in the database, we can see that these stored procedures seem like the "interface" concept in our programming. For systems with high security requirements, such as banks, most common operations are performed through stored procedures or functions, so that the applications are completely "hidden" tables. Of course, there are also disadvantages: 1. the stored procedure will increase the system resources occupied by the database (cpu and memory). after all, the database is mainly used for data access and does not perform complex business logic operations. 2. because the stored procedure is still SQL, it is impossible to write the stored procedure corresponding to the complex business logic as the programming language. 3. the stored procedure is not easy to debug. 4. it is difficult to write and maintain stored procedures. Understanding these advantages and disadvantages will greatly help the author rdardabitsCN.com to weigh the use of stored procedures.

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.