MySQL DELIMITER 语法错误
这个 MySQL 脚本安装了多个触发器.
This MySQL script installs multiple triggers.
它适用于一台运行 MySQL 5.0.51b-community 的机器.在另一台运行 MySQL 14.12 Distrib 5.0.45 的机器上,对于 redhat-linux-gnu (i386),它失败,并显示此错误消息,这似乎与 DELIMITER//...//DELIMITER
;语法:
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 :
第 272 行的 ERROR 1064 (42000):您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以获取在DELIMITER"附近使用的正确语法;DROP TRIGGER IF EXISTS trigger_name;DELIMITER' 在第 1 行
脚本语法(总结)是:
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?
推荐答案
尝试
DELIMITER ;
不是
DELIMITER;
您实际上将 ;
指定为 DELIMITER
命令的参数,因此没有空格可能会混淆它.
You're actually specifying ;
as an argument to the DELIMITER
command, so not having the space there may be confusing it.
相关文章