简体   繁体   English

MySQL 分隔符语法错误

[英]MySQL delimiter syntax error

I'm trying to change the MySQL command delimiter so I can create a procedure with multiple commands in it.我正在尝试更改 MySQL 命令分隔符,以便我可以创建一个包含多个命令的过程。 However, the delimiter command does not seem to be recognised on MySQL 5.1.47.但是,在 MySQL 5.1.47 上似乎无法识别分隔符命令。 I tested it on MySQL 5.0.91, and it did work there.我在 MySQL 5.0.91 上测试了它,它确实在那里工作。

DELIMITER //;
DELIMITER ;//

I'm trying to run this from phpmyadmin, in both situations.在这两种情况下,我都试图从 phpmyadmin 运行它。 Using 5.0.91 instead isn't an option because I need to use events ( CREATE EVENT ).改用 5.0.91 不是一种选择,因为我需要使用事件( CREATE EVENT )。

Error message:错误信息:

#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 

Is there a reason it's not working, or is there an alternative to accomplish the same thing (creating a procedure with multiple queries)?是否有它不起作用的原因,或者是否有其他方法可以完成相同的事情(创建具有多个查询的过程)?

DELIMITER is not a MySQL command. DELIMITER不是 MySQL 命令。 It's a command that your MySQL client needs to support.这是您的 MySQL 客户端需要支持的命令。 I was running PHPMyAdmin 2.8.2.4, which didn't support it.我正在运行 PHPMyAdmin 2.8.2.4,它不支持它。 When I upgraded to the newest version, which is currently 3.4.9, it worked just fine.当我升级到最新版本(目前是 3.4.9)时,它运行得很好。 Your MySQL version has nothing to do with DELIMITER and whether it's supported or not.您的 MySQL 版本与DELIMITER以及是否受支持无关。

You don't need to delimit the DELIMIT statements您不需要分隔 DELIMIT 语句

DELIMITER //

procedure here etc

DELIMITER ;

Exactly as per "Defining Stored Programs" in the MySQL docs.完全按照 MySQL 文档中的“定义存储程序”

And if you can control versions, the latest is 5.5.20.如果可以控制版本,最新的是5.5.20。 Why not use that?为什么不使用它?

Edit:编辑:

The error message indicates an error in the previous statement... if this can't be seem force it thus错误消息表明前一条语句中存在错误...如果这似乎不能强制执行

; /* <- force previous statement termination */ DELIMITER //

procedure here etc

DELIMITER ;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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