MySQL触发器触发更改或删除 [英] MySQL trigger to fire on alter or drop

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

问题描述

我遇到了一个有趣的问题.我想创建两个触发器,触发器1将在DROP TABLE上触发,触发器2将在ALTER TABLE上触发.如果要删除或更改任何表,我希望触发器1和触发器2触发,但是,不幸的是,我不知道执行该操作的语法,而且我也找不到此类触发器的语法.在MySQL中,我只能编写在INSERTUPDATEDELETE之前/之后触发的触发器,但是现在我想编写适用于数据库级别并在表事件上触发的触发器.有人可以帮我吗?

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

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

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