简体   繁体   English

SQL Server视图,它会更新自己,还是需要我创建一个新的?

[英]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.

相关问题 OleDB vs ODBC:是否其中之一不需要为所有Oracle,MySQL,SQL Server安装驱动程序? - OleDB vs ODBC: does one of them NOT require driver installation FOR ALL Oracle, MySQL, SQL Server? 在SQL Server中创建新行 - Create a new line in SQL Server 创建视图正在重定向到其自身 - The Create View is redirecting to itself 更新所有在其中创建新对象的对象 - Update all objects where create new one Stripe:更新订阅还是取消并创建新订阅? - Stripe: Update subscription or cancel and create new one? 带有 EF6 的 WPF 应用程序不会在 SQL Server Enterprise 中创建新数据库 - WPF application with EF6 does not create new database in SQL Server Enterprise DataFormats.GetFormat 是否允许我创建新的私有格式? - Does DataFormats.GetFormat allow me to create a new private format? 按钮单击不更新 SQL Server 表 - Button Click Does Not Update SQL Server Table 缓存存储库的结果,或者可能是sql server为我做的 - cache repository's result or maybe sql server does it for me 从sql服务器数据库迁移到不需要客户端安装服务器的数据库(C#Entity Framework) - Moving from a sql server database to one that doesn't require the client to install a server (C# Entity Framework)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM