MySQL stored procedure authoring-Getting Started case-ground tornado

Source: Internet
Author: User

(-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

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.