[英]SQL Server view, will it update itself, or does it require me to create a new one?
A view is created, and certain users have direct access to the database using the same web application. 创建视图,并且某些用户可以使用同一Web应用程序直接访问数据库。 If the base table is changed (data) will the view automatically reflect the changes/insert in data, or will it need to be created again and again?
如果更改基表(数据),视图是否会自动反映数据中的更改/插入,还是需要一次又一次地创建?
Visual Studio 2008, SQL Server 2005, C#. Visual Studio 2008,SQL Server 2005,C#。
Views are like windows, they just let you see what's in the table. 视图就像窗口,它们只是让你看到表中的内容。 They don't contain a copy of the table or anything like that.
它们不包含表格的副本或类似的东西。
If you change the definition of the table, like add or remove a column, you should rebuild the view. 如果更改表的定义(如添加或删除列),则应重建视图。 But if you are just doing insert/update/delete, then everything will just work.
但是如果你只是在进行插入/更新/删除,那么一切都会正常工作。
Views recalculate themselves automatically. 视图会自动重新计算。 When this happens depends on the specific engine in use (read: I have no clue when for SQL Server 2005).
发生这种情况取决于使用的特定引擎(读取:我对SQL Server 2005时没有任何线索)。
In effect, a view is a just a pre-written select statement. 实际上,视图只是一个预先编写的select语句。
Every time you make a call to the database for a particular view, the select statement runs and the current dataset in the base table(s) is returned. 每次为特定视图调用数据库时,都会运行select语句,并返回基表中的当前数据集。
You won't see live changes in an application front-end if someone else makes a change to the data table but you will see any changes as soon as you make a new request for the view. 如果其他人对数据表进行了更改,您将不会在应用程序前端看到实时更改,但只要您对视图发出新请求,就会看到任何更改。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.