在删除级联上不触发触发器 [英] on delete cascade not firing trigger

查看:96
本文介绍了在删除级联上不触发触发器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为"player_instance"的表,然后有一个名为"penalties"的表(该表具有引用player_instance的外键).我还有一个名为分数"的表.

I have a table called 'player_instance' and then a table called 'penalties' (which has a foreign key referencing player_instance). I also have a table called 'scores'.

我对罚则有DELETE TRIGGER,这样,如果删除一行,它将改变分数列.我知道这行得通-删除罚分后,分数会减少.

I have a DELETE TRIGGER on penalties such that if a row is deleted then it will alter a column in scores. I know this works - when a penalty is deleted it will decrease a column in scores.

我还有一个ON DELETE CASCADE,如果删除了player_instance,那么所有相关的罚款也将被删除.我知道这也可以.

I also have a ON DELETE CASCADE where if player_instance is deleted then all associated penalties will also be deleted. I know this works too.

但是当删除player_instance时,它只会删除相关的惩罚,而不会触发更改分数的触发器.谁能帮助我了解为什么这不起作用?

But when player_instance is deleted it will only delete the relevant penalties and not fire the trigger to alter scores. Can anyone help me understand why this is not working?

非常感谢

推荐答案

触发器未通过外键动作激活."

'Triggers are not activated by foreign key actions.'

http://dev.mysql.com/doc/refman/5.5/en/stored-program-restrictions.html

啊!

有人可以帮助我解决问题吗?

Can anyone help me with a workaround?

这篇关于在删除级联上不触发触发器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆