CREATE TRIGGER backupFIDE AFTER UPDATE ON player
FOR EACH ROW
BEGIN
IF (OLD.FIDERating <> NEW.FIDERating) THEN
INSERT INTO playerbackup(PlayerName, OldFIDERating, NewFIDERating)
VALUES(OLD.PlayerName, OLD.FIDERating, NEW.NewFIDERating)
END;
大家好,因为某些原因在第6行收到语法错误,一直在网上寻找可能是原因的解决方案。基本上看一个简单的触发器,它会将Player表中FIDERating的更改更改复制到包含OldFIDERating的备份表,然后更改它,并进行NewFIDERating以及日期更改。
答案 0 :(得分:0)
DELIMITER //
CREATE TRIGGER backupFIDE AFTER UPDATE ON player
FOR EACH ROW
BEGIN
IF NEW.FIDERating <> OLD.FIDERating
THEN
INSERT INTO playerbackup(PlayerName, OldFIDERating, NewFIDERating)
VALUES(OLD.PlayerName, OLD.FIDERating, NEW.NewFIDERating);
END IF;
END;
//
DELIMITER ;