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中執(zhí)行有錯(cuò),錯(cuò)誤信息如下:
查詢:create trigger tt1 after insert on t1 for each row begin insert into `t2` (`t2_id`) values (new.t1_id)
錯(cuò)誤代碼: 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
執(zhí)行耗時(shí) : 0 sec
傳送時(shí)間 : 0 sec
總耗時(shí) : 0.001 sec
--------------------------------------------------
查詢:end
錯(cuò)誤代碼: 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
執(zhí)行耗時(shí) : 0 sec
傳送時(shí)間 : 0 sec
總耗時(shí) : 0 sec
然后我嘗試著將 觸發(fā)器中的insert into...這條語(yǔ)句注釋掉,然后再執(zhí)行就成功了;
再去改變觸發(fā)器,將注釋去掉,同樣成功了;
請(qǐng)問為什么直接寫就會(huì)報(bào)錯(cuò)呢?
總結(jié)
以上是生活随笔為你收集整理的mysql触发器报错_mysql触发器实例:莫名其妙的错误?的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Android学习笔记(十三)
- 下一篇: Windows Store App 获取