可更新视图 - SQL Server 2008
关于可更新数据库视图的问题:我正在阅读有关该主题的一些 MSDN 文档,并且遇到以下限制:
任何修改(包括 UPDATE、INSERT 和 DELETE 语句)都必须仅引用一个基表中的列。
我只是想确保我理解该限制。我想在我的几个媒体评论项目中使用视图。关系数据分布在整个表中,但视图似乎是将多个表(其中一些通过外键链接)中所需的数据合并到集中位置的最佳方式。由于这些列来自各种表,这是否意味着我无法运行一个一揽子 INSERT 或 UPDATE 来保留所有列中的更改?
A question about updatable db views: I'm reading through some MSDN documentation on the subject, and I come across the following restriction:
Any modifications, including UPDATE, INSERT, and DELETE statements, must reference columns from only one base table.
I just want to be sure I understand the restriction. I'd like to use views in a couple of my media review projects. The relational data is spread throughout tables, but a view seems to be the best way to be able to consolidate the data I need from multiple tables (some of which are linked via foreign keys) into a centralized location. Since the columns would come from a variety of tables, does this mean I can't run one blanket INSERT or UPDATE to persist changes in all the columns?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以在视图上使用 INSTEAD OF 触发器,以使应用程序仅处理视图而不是视图引用的基表集合。
这是一个示例:设计而不是触发器
You can use an INSTEAD OF trigger on a view to keep your application only dealing with the view instead of the collection of base tables the view references.
Here is an example : Designing INSTEAD OF Triggers
是的,就是这个意思。我认为通过视图更新没有任何优势,因为无论如何您都必须知道所涉及的基表是什么。
Yes that's what it means. I see no advantage to updating through a view since you have to know what the base tables involved are anyway.