MySQL 触发器导致错误 #1064

发布于 2024-10-02 09:41:49 字数 388 浏览 2 评论 0原文

我尝试在 MySQL 中编写这个小触发器,

CREATE TRIGGER `leg` BEFORE INSERT ON `bckoff` 
FOR EACH ROW BEGIN
 INSERT INTO `bckoff` SET `step`=1;
END;

之后我收到此错误..我是 MySQL 的新手..所以请在这里帮助我..

#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 '' at line 3 

I tried writing this small trigger in MySQL,

CREATE TRIGGER `leg` BEFORE INSERT ON `bckoff` 
FOR EACH ROW BEGIN
 INSERT INTO `bckoff` SET `step`=1;
END;

after which I get this error.. I'm a newbie to MySQL.. so please help me out here..

#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 '' at line 3 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

眼泪淡了忧伤 2024-10-09 09:41:49

即使修复了此错误 - 您还会遇到另一个错误:您无法修改创建触发器的表。

顺便说一句,这就是您应该如何创建此触发器:

delimiter |

CREATE TRIGGER `leg` BEFORE INSERT ON `bckoff` 
FOR EACH ROW BEGIN
 INSERT INTO `bckoff` SET `step`=1;
END;
|

delimiter ;

Even after you fix this error - you'll get another one: you cannot modify the table that your trigger was created at.

Btw, this is how you should create this trigger:

delimiter |

CREATE TRIGGER `leg` BEFORE INSERT ON `bckoff` 
FOR EACH ROW BEGIN
 INSERT INTO `bckoff` SET `step`=1;
END;
|

delimiter ;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文