Reprinted: http://www.phppan.com/2010/05/mysql-delimit/
Delimiter problems encountered during the first MySQL storage write process
I wrote the Oracle stored procedure a long time ago. Yesterday, due to some special reasons, I had to write some stored procedures in MySQL.
First, I wrote a very simple stored procedure, but an error is returned for such a simple procedure. The Code is as follows:
12345 |
CREATE PROCEDURE test()BEGIN SELECT 'Hello Word!'; END |
Errors are reported on both phpMyAdmin and the client. It is displayed in phpMyAdmin: #1064-you have an error in your SQL syntax; check the manual that corresponds to your MySQL Server version for the right syntax to use near "at line 3
Apparently, an error occurred after the first semicolon.
Unknown reason, then Google, find the following address: http://www.cnblogs.com/hsqzzzl/archive/2008/02/21/1076646.html
The author of the article said: the separator is a symbol that notifies the mysql client that the input has been completed. ";" Is always used, but not in the stored procedure, because many statements in the Stored Procedure need to use semicolons
The Code is as follows:
123456 |
DELIMITER ||CREATE PROCEDURE test()BEGIN SELECT 'Hello Word!'; END ||DELIMITER ; |
If you do not want to use delimiter, enter it in the delimiter text box when executing the command in phpMyAdmin. |
Another in Baidu encyclopedia has instructions: http://baike.baidu.com/view/3068266.htm
The delimit command in MySQL.
This command has nothing to do with stored procedures.
In fact, it is to tell the MySQL interpreter whether the command has ended and whether MySQL can be executed.
That is, the input Terminator is changed.
By default, Delimiter is a semicolon (;).
In the command line client, if a command line ends with a semicolon,
After you press enter, MySQL will execute this command.
But sometimes, you don't want MySQL to do this. The statement may contain semicolons.
By default, it is impossible for the user to execute the entire statement after entering all these statements.
MySQL runs automatically when it encounters a semicolon.
In this case, you can use delimiter to replace delimiter with other symbols, such as // or $.
In this case, Delimiter is used to encapsulate the entire short statement.
This command is used in defining subprograms, triggering programs, and other musql embedded mini programs.