(-1) write in front
This article is a brief description of the basic concepts of MySQL stored procedure writing.
the MySQL version I am using is 5.7.9-log.
reference << mysql>> in layman 's .
(0) Delimiter//
Delimiter// /// can be specified as a different symbol, such as delimiter @@, to change the end of the statement identifier.
because it is used in the stored procedure , it does not change the end of the default statement. The logo will be an error.
After you create the stored procedure, don't forget to change the default end ID yourself!
(1) creation of stored procedures
in the MySQL command line tool Enter the following code , Of course you can also use in the visualizer, but we recommend the use of the command line.
Mysql> delimiter//
Mysql> CREATE PROCEDURE Fine ()
Begin
Set @x = 1;
-End//
Query OK, 0 rows Affected (0.00 sec)
(2) The adjustment of the stored procedure
Mysql> call Fine ()//
Query OK, 0 rows Affected (0.00 sec)
To view the execution results :
Mysql> Select @x//
+------+
| @x |
+------+
| 1 |
+------+
1 row in Set (0.00 sec)
(3) Viewing stored procedures
A. viewing the definition of a stored procedure
Show CREATE PROCEDURE fine/g
/g easy to see results
definition : How to create a stored procedure.
B. viewing the status of a stored procedure
Show procedure status like ' fine ' \g
or switch the database using the use Information_schema
SELECT * from routines where routine_name = ' fine ' \g
status : The State of the stored procedure that already exists.
INFORMATION_SCHEMA is a database that comes with MySQL.
MySQL stored procedure authoring-Getting Started case-ground tornado