简体   繁体   中英

DELIMITER MYSQL

I'm trying to create a delimiter, I use Mysql version 8.0 on Ubuntu and when I run the command it returns a syntax error:

SQL Error [1064] [42000]: 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 $$ CREATE TRIGGER trigger1 BEFORE INSERT ON whatsapps FOR EACH ROW BEG' at line 1
Error position:

    DROP TRIGGER IF EXISTS trigger1; 
    DELIMITER $$ CREATE TRIGGER trigger1 
BEFORE INSERT ON whatsapps FOR EACH ROW BEGIN SELECT COUNT(*) INTO @cnt FROM whatsapps; 
    IF @cnt >= 2 THEN CALL sth(); 
    END IF; 
END $$ 
DELIMITER ; 

Can anyone understand which syntax is wrong?

DELIMITER must be on its own line.

DELIMITER uses all of the content until the end of the line to define the delimiter. So in your example, you have set the delimiter to this string of 27 characters: "$$ CREATE TRIGGER trigger1 "

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM