开发者

SQL Server view, will it update itself, or does it require me to create a new one?

开发者 https://www.devze.com 2023-01-04 16:01 出处:网络
A view is created, and certain users have direct access to the database using the same web application. If the base table is changed (data) will the view automatically reflect the ch开发者_JAVA百科ang

A view is created, and certain users have direct access to the database using the same web application. If the base table is changed (data) will the view automatically reflect the ch开发者_JAVA百科anges/insert in data, or will it need to be created again and again?

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).


In effect, a view is a just a pre-written select statement.

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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消