Can we use semicolon as a MySQL DEMILITER?

MySQLMySQLi Database

No, we cannot. If you still did it, then stored procedure won’t get created. Therefore, first you need to change your DELIMITER from semicolon(;) to others like (// ,??..etc). Following is the syntax −

DELIMITER //
CREATE PROCEDURE yourProcedureName()
BEGIN
yourStatement1,
.
.
.
.
N
END
//
DELIMITER ;

Let us implement the above syntax in order to create a stored procedure −

mysql> DELIMITER //
mysql> CREATE PROCEDURE get_Message()
   -> BEGIN
   -> SELECT CONCAT("HELLO"," ","MYSQL USERS");
   -> END
   -> //
Query OK, 0 rows affected (0.23 sec)
mysql> DELIMITER ;

Now you can call the stored procedure with the help of CALL command −

mysql> CALL get_Message();

Output

This will produce the following output −

+-----------------------------------+
| CONCAT("HELLO"," ","MYSQL USERS") |
+-----------------------------------+
| HELLO MYSQL USERS                 |
+-----------------------------------+
1 row in set (0.00 sec)
Query OK, 0 rows affected (0.01 sec)
raja
Published on 09-Jul-2019 14:16:37
Advertisements