首页 > 编程知识 正文

mysql触发器语法,mysql语法错误

时间:2023-05-03 13:46:41 阅读:222025 作者:4543

This MySQL script installs multiple triggers.

It works on one machine running MySQL 5.0.51b-community. On another machine running MySQL 14.12 Distrib 5.0.45, for redhat-linux-gnu (i386) it fails, with this error message, which seems to be related to the DELIMITER // ... // DELIMITER; syntax :

ERROR 1064 (42000) at line 272: 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; DROP TRIGGER IF EXISTS trigger_name; DELIMITER' at line 1

The script syntax (summarised) is:

DROP TRIGGER IF EXISTS trigger_name;

DELIMITER //

CREATE TRIGGER trigger_name BEFORE UPDATE ON table

FOR EACH ROW BEGIN

-- Trigger logic goes here

END //

DELIMITER;

-- More trigger drop/create statements follow

What is wrong with the script, and how can I correct it?

Try

DELIMITER ;

not

DELIMITER;

You're actually specifying ; as an argument to the DELIMITER command, so not having the space there may be confusing it.

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。