MySQL delimiter defines the end mark of a command

Source: Internet
Author: User

The following articles mainly introduce the end mark of the MySQL delimiter definition command. We all know that by default, MySQL delimiter is a semicolon ;. In the client of the command line, if a line of command ends with a semicolon, press enter and MySQL will execute this command.

Enter the following statement.

 
 
  1. MySQL> select * from test_table; 

Press enter, and MySQL will immediately execute the statement.

But sometimes, you don't want MySQL to do this. The statement contains a semicolon.

For example, enter the stored procedure in the command line:

 
 
  1. MySQL> create procedure simpleproc (out paraml int)  
  2. -> begin  
  3. -> select count(*) into paraml from user;  
  4. -> end  

In this case, MySQL delimiter is used to change the default end mark:

 
 
  1. MySQL> delimiter //  
  2. MySQL> create procedure simpleproc (out paraml int)  
  3. -> begin  
  4. -> select count(*) into paraml from user;  
  5. -> end  
  6. -> // 

Then you can change it back to the original semicolon and test the stored procedure.

 
 
  1. MySQL> delimiter ;  
  2. MySQL> call simpleproc(@a);  
  3. Query OK, 0 rows affected (0.00 sec)  
  4. MySQL> select @a;  
  5. +------+  
  6. | @a |  
  7. +------+  
  8. | 5 |   
  9. +------+  
  10. 1 row in set (0.00 sec)  

The above content is an introduction to the end mark of the MySQL delimiter-defined command. I hope you will get something.
 

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.