是否可以在 information_schema 中的任何表上应用触发器?
是否可以在 information_schema 中的任何表上应用触发器?
Is it possible to apply trigger on any table in information_schema?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
据我了解,information_schema 中的表实际上是视图。 此处提到了这一点。
根据 MySQL 的规定,您不能在临时表或视图上创建触发器。有关相关讨论,请参阅此页面。
所以,根据这些信息我会说不。我确信如果我在这一点上错了,有人会纠正我。
有一个类似于您所要求的讨论此处。
你想实现什么目标?
It is my understanding that the tables in information_schema are really views. This is mentioned here.
According to MySQL, you can't make triggers on temp tables or views. See this page for a discussion about that.
So, I'm going to say no based on that information. I'm sure someone will correct me if I'm wrong on this.
There is a discussion similar to what you are asking here.
What are you trying to accomplish?
那里有更聪明的人——
开玩笑,但不幸的是,我一直在尝试做同样的事情,唯一明显的答案是添加一个抽象层。
简而言之,您需要用另一种语言调用更高级别的函数(由您自己编写),而不只是 SQL("ALTER TABLE ...."),如下所示:
->
我真的很想直接在 DBMS 中执行此操作,但似乎 information_schema 并不是为此目的。
当然,您会希望在一笔交易中拥有所有这些,以确保它不会爆炸;)
Someone smarter is there --
Just kidding but I've been trying to do the same thing and the only obvious answer is to add an abstraction layer, unfortunately.
Simply put, instead of just SQL("ALTER TABLE ....") you will need to call a higher level function (written by yourself) in another language, like this:
->
I really wanted to do this straight in the DBMS, but it seems like information_schema wasn't meant for that.
And of course, you'll want to have all that in one transaction, to make sure it doesn't explode ;)