What is a stored procedure:
Stored procedures can be said to be a recordset bar, it is a code block consisting of some T-SQL statements that implement functions like a method (check for additions or deletions to a single table or multiple tables), and then give the code block a name and call him when it comes to this feature.
Benefits of Stored procedures:
1. Because the database executes the action, it is compiled and executed first. However, the stored procedure is a compiled block of code, so the execution efficiency is higher than the T-SQL statement.
2. A stored procedure can replace a large number of T-SQL statements when the program interacts in the network, so it can also reduce the traffic of the network and increase the rate of communication.
3. The stored procedures enable users without permission to access the database indirectly under control, thereby ensuring data security.
Summary: In short, stored procedures are good things, in doing the project is an essential tool, the following describes the basic syntax of the stored procedure.
1. Stored Procedure Syntax
CREATE PROCEDURE proc_name ([in| Out| INOUT] param data type)
BEGIN
statement
end
Under the MySQL command line, each statement must be separated by a (semicolon), semicolon is a MySQL execution point, and the delimiter//command is used to convert the separator to//for the write stored procedure.
Delimiter//
2. Write a simple procedure
mysql-> CREATE PROCEDURE Hello ()
-> BEGIN
-> SELECT "Hello world!";
-> End
->//
Query OK, 0 rows Affected (0.00 sec)
1. Calling a stored procedure: Call Proc_name
Mysql-> call Hello ()//
+----------------------+
| It's a Hello world. |
+----------------------+
| It's a Hello world. |
+----------------------+
1 row in Set (0.00 sec)
2. Delete stored Procedures
Note: You can call another stored procedure in one stored procedure, but you cannot delete it.
The above is a small set to introduce the MySQL stored process Learning knowledge Summary of the relevant knowledge, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!