MySQL触发器触发更改或删除
我遇到了一个有趣的问题.我想创建两个触发器,触发器1将在DROP TABLE
上触发,触发器2将在ALTER TABLE
上触发.如果要删除或更改任何表,我希望触发器1和触发器2触发,但是,不幸的是,我不知道执行该操作的语法,而且我也找不到此类触发器的语法.在MySQL中,我只能编写在INSERT
,UPDATE
或DELETE
之前/之后触发的触发器,但是现在我想编写适用于数据库级别并在表事件上触发的触发器.有人可以帮我吗?
I've encountered an interesting problem. I would like to create two triggers, trigger1 would fire on DROP TABLE
and trigger2 on ALTER TABLE
. I would like trigger1 and trigger2 to fire if any table is dropped or altered, but, unfortunately I don't know the syntax to do that and I couldn't find a syntax for such triggers either. In MySQL I can only write triggers which fire before/after INSERT
, UPDATE
, or DELETE
, but now I would like to write triggers which would be applicable on database level and would fire on table events. Can somebody help me?
您正在寻找的被称为"DDL触发器". MySQL不支持它们
What you are looking for is known as "DDL Triggers". MySQL does not support them
存在 SourceForge请求,但我不确定如何认真的人都在添加它
There is this SourceForge request but I'm not sure how serious anyone is about adding it