而不是视图上的触发器 - 用例是什么?
我们的生产数据库已经有 5-7 年的历史了,在这段时间里,很多人都参与过它的架构修改。我刚刚发现我们的一些观点有替代触发器。我什至不知道这是可能的。对于那些使用过而不是视图上的触发器的人来说,您试图解决什么用例?考虑到这样做的可维护性,我很难看到这样做的好处。
非常感谢。
Our production database is 5-7 years old, and many people have had their hands in it making schema modifications during this time. I just discovered there are Instead Of triggers on some of our views. I didn't even know this was possible. For those of you who have used Instead of triggers on views, what use case were you trying to solve? I'm having a hard time seeing the benefit of this, given the maintainability of doing such a thing.
Thanks very much.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我没有使用过它们,但我认为主要用途是允许在视图上执行 INSERT/UPDATE 语句,并且让这些语句实际上在视图下潜在地插入/更新多个表。
I haven't used them, but the I think the primary use is allowing INSERT/UPDATE statements to be performed on the view, and having those statements actually INSERT/UPDATE potentially multiple tables underneath the view.
我使用它们提供了一个与现有应用程序期望找到的表兼容的模式,但实际上在完全不同的模式上执行操作。这是将错误跟踪数据库系统集成到具有现有用户会员系统的数据库中。因此,错误跟踪系统期望找到的用户表被伪造为视图,并实现了 INSTEAD OF 触发器来对已经存在的会员系统进行更改。
I have used them to provide a schema which is compatible with a table that an existing application expects to find, but actually perform operations on a completely different schema. This was integrating a bug tracking database system into a database which had an existing user membership system. So the users table that the bug tracking system expected to find was faked up as a view, and INSTEAD OF triggers were implemented to make changes to the membership system that already existed.
如果您共享代码,我们可能会猜测您的用例。除了 Chris Shaffer 所说的之外,这些可能是为了强制执行特定的数据完整性要求(尽管说实话,我希望这些在表上而不是视图上),或者向用户通常不会意识到的字段添加信息。
We could probably guess the use case for you if you shared the code. Besides what Chris Shaffer said, these could be to enforce specific data integrity requirements (although truthfully I would expect these on the table not the view) or to add information to fields the user would not normally be aware of.