Must I use delimiter
in Mysql to create a procedure?
-
1Does this answer your question? [Delimiters in MySQL](https://stackoverflow.com/questions/10259504/delimiters-in-mysql) – Slava Rozhnev Aug 29 '20 at 22:37
-
No. There are some trivial stored procedures that you can write without a delimiter. However, it is best to be in the habit of always using a delimiter. – Gordon Linoff Aug 29 '20 at 22:45
2 Answers
Yes you must - unless your procedure is made of a single statement. This is well explained in the documentation:
Each stored program contains a body that consists of an SQL statement. This statement may be a compound statement made up of several statements separated by semicolon (
;
) characters.[...]
If you use the mysql client program to define a stored program containing semicolon characters, a problem arises. By default, mysql itself recognizes the semicolon as a statement delimiter, so you must redefine the delimiter temporarily to cause mysql to pass the entire stored program definition to the server.
To redefine the mysql delimiter, use the
delimiter
command. [...] This enables the;
delimiter used in the procedure body to be passed through to the server rather than being interpreted by mysql itself.

- 216,147
- 25
- 84
- 135
Yes in a Query tab or in the mysqlclient you need them as described here
The problem is a semicolon is the end of a command, but in a stored procedure all semicolons a prt of the stored procedure.
Mysql has to now when he must interpret, the semicolons as part of the procedure by having the DELIMITER changed

- 45,398
- 8
- 30
- 47