mysql触发器报错_mysql触发器实例:莫名其妙的错误?
DROP TRIGGER IF EXISTS tt1;
CREATE TRIGGER tt2
AFTER INSERT ON t1
FOR EACH ROW
BEGIN
INSERT INTO `t2` (`t2_id`) VALUES (new.t1_id);
END;
上面這段代碼在SQLyog中執行有錯,錯誤信息如下:
查詢:create trigger tt1 after insert on t1 for each row begin insert into `t2` (`t2_id`) values (new.t1_id)
錯誤代碼: 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 5
執行耗時 : 0 sec
傳送時間 : 0 sec
總耗時 : 0.001 sec
--------------------------------------------------
查詢:end
錯誤代碼: 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 'end' at line 1
執行耗時 : 0 sec
傳送時間 : 0 sec
總耗時 : 0 sec
然后我嘗試著將 觸發器中的insert into...這條語句注釋掉,然后再執行就成功了;
再去改變觸發器,將注釋去掉,同樣成功了;
請問為什么直接寫就會報錯呢?
總結
以上是生活随笔為你收集整理的mysql触发器报错_mysql触发器实例:莫名其妙的错误?的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Android学习笔记(十三)
- 下一篇: Windows Store App 获取