Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysql: DELIMITER syntax error at line 1

I try to add this function using the following SQL in phpmyadmin/MySQL

DROP FUNCTION IF EXISTS `__myv`;
DELIMITER ;;
CREATE   FUNCTION `__myv`(`a` int, `b` int) RETURNS bigint(20)
BEGIN

    return FLOOR(a / b);
END;;
DELIMITER ;

but I get this error:

Error

SQL query:

DELIMITER;

MySQL said: Documentation
#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 'DELIMITER' at line 1 

How to fix this error??

like image 388
Alex.DX Avatar asked Dec 01 '13 14:12

Alex.DX


People also ask

How do I get out of delimiter in MySQL?

You can redefine the delimiter to a string other than // , and the delimiter can consist of a single character or multiple characters. You should avoid the use of the backslash ( \ ) character because that is the escape character for MySQL.

What is delimiter error?

The MySQL delimiter occurs when you are using a pipe delimiter(|) with semicolon (;) and using MySQL version lower than 8.0. 12. MySQL treats the pipe (|) as one delimiter and semicolon (;) is another delimiter.

What does delimiter mean in MySQL?

You define a DELIMITER to tell the mysql client to treat the statements, functions, stored procedures or triggers as an entire statement. Normally in a . sql file you set a different DELIMITER like $$. The DELIMITER command is used to change the standard delimiter of MySQL commands (i.e. ;).

What is a MySQL syntax error?

The MySQL 1064 error is a syntax error. This means the reason there's a problem is because MySQL doesn't understand what you're asking it to do. However, there are many different situations that can lead to this type of miscommunication between you and your database.


1 Answers

DELIMITER is a Mysql console command, You can't use it in phpmyadmin. To set the delimiter in phpmyadmin, see this other answer

like image 148
Filipe Silva Avatar answered Oct 12 '22 23:10

Filipe Silva