The following articles mainly introduce the actual operation process of the MySQL stored procedure, including the syntax description of the stored procedure and the description of related commands, if you are interested in the actual operations, you can click to read the following articles.
Stored Procedure syntax
- Create procedure proc_name ([IN | OUT | INOUT] param data type)
- BEGIN
- Statement
- END
In the MySQL command line, each statement must be separated by a semicolon (semicolon), which is the execution point of MySQL. In order to write the MySQL stored procedure, the delimiter // command is used to convert the separator //.
- delimiter //
Write a simple procedure
- MySQL-> CREATE PROCEDURE hello()
- -> BEGIN
- -> SELECT "Hello World!";
- -> END
- -> //
- Query OK, 0 rows affected (0.00 sec)
Call the MySQL stored procedure: call proc_name
- MySQL-> CALL hello()//
- +----------------------+
- | it is a hello world. |
- +----------------------+
- | it is a hello world. |
- +----------------------+
- 1 row in set (0.00 sec)
Delete stored procedure
- DROP proc_name
Note: A stored procedure can call another MySQL stored procedure, but cannot be deleted.