我正在尝试创建一个记录更新事件的简单触发器。但是我接近"开始......"。如果我使用单引号,即' update_log'和'客户'然后错误接近' ' update_log中....'
use tal;
delimiter //
CREATE TRIGGER onUpdate
BEFORE UPDATE ON customer
BEGIN
INSERT INTO update_log VALUES(user(), 'An Udpdate operation against the customer table.', now());
END//
delimiter ;
为什么这不起作用?
答案 0 :(得分:1)
与Oracle mysql不同,需要FOR EACH ROW
delimiter //
CREATE TRIGGER onUpdate
BEFORE UPDATE ON customer
FOR EACH ROW
BEGIN
INSERT INTO update_log VALUES(user(), 'An Udpdate operation against the customer table.', now());
END//
delimiter ;