MySQL Stored Procedure Learning

Source: Internet
Author: User
Tags mysql command line
  1. 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 stored procedure, use the delimiter // command to convert the separator //.
    Delimiter //

  2. Write a simple procedure
    Mysql-> Create procedure Hello ()
    -> Begin
    -> Select "Hello world! ";
    -> End
    -> //
  3. Query OK, 0 rows affected (0.00 Sec)

  4. Call 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)
  5. Delete stored procedure
    Drop proc_name
    Note: A stored procedure can call another stored procedure, but cannot be deleted.

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.