我们可以在视图中编写更新和删除查询吗?

问题描述:

在 SQL Server 2005 中,我使用 SELECT 语句创建了一些视图.我们可以在视图中编写 UPDATEDELETE 语句吗?

In SQL Server 2005, I have some views created by using a SELECT statement. Can we write UPDATE and DELETE statements in views?

好吧,如果这是您的要求,您可以从视图中删除,但您不能拥有删除信息的视图.视图是来自基础表的数据的一部分.只要您有权限,您就可以在视图中进行与直接对表进行相同的数据操作.

Well you can delete from a view if that is what you are asking, but you can't have a view that deletes information. The view is a portion of data from the underlying tables. Provided that you have permissions, you can do the same data manipulation in views that you can do to a table directly.

因此您可以执行以下操作:

So you can do something like:

DELETE FROM my_View WHERE id = 3;

何时使用视图
什么是视图