Definition of mysql Stored Procedure Variables

Source: Internet
Author: User

Definition of mysql Stored Procedure Variables

Mysql variables:

1. DECLARE variable_name datatype (size) DEFAULT default_value;

The declaration here is equivalent to a local variable and will expire after the end.

DECLARE multiple: DECLARE x, y int default 0

 

2. set @ p = 1;

The session variable does not need to be declared here. mysql automatically determines the type based on the value type. This variable must be preceded by the variable name with the "@" symbol, which is called the session variable, it indicates that the entire session process is effective, which is similar to a global variable. This variable is widely used because it can share data between called stored procedures or codes as long as it is in a session (that is, a connection process of an application.

 

3. assign values to variables. In addition to set, you can also use the select... into... method.

 

Reference: http://blog.csdn.net/rdarda/article/details/7878836

Related Article

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.