这是我的代码
CREATE TRIGGER backup AFTER DELETE ON game
FOR EACH ROW
BEGIN
INSERT INTO devhistory(gid,title,released,client)
SELECT gid,title,released,client
FROM game;
END
但是这会将整个表添加到devhistory中,因为我只想插入被我删除的行。
(phpmyAdmin说如果我尝试使用DELETED虚拟表,则不存在表DELETED。)
编辑:已解决
CREATE TRIGGER backup AFTER DELETE ON game
FOR EACH ROW
BEGIN
INSERT INTO devhistory(gid,title,released,client)
SELECT old.gid,old.title,old.released,old.client
FROM game;
END
可以工作,但会将相同的数据写入devhistory(游戏中的行数)次。
谢谢@ splash58