Are Views automatically updated

前端 未结 6 1415
谎友^
谎友^ 2021-02-02 05:40

If I JOIN or CROSS APPLY two tables and create a VIEW, will the view automatically gets updated when I update either of the two tables or

6条回答
  •  囚心锁ツ
    2021-02-02 05:54

    Yes, they are updated, every time you use them.

    I think Microsoft sums up what a View is quite clearly:

    A view can be thought of as either a virtual table or a stored query.

    http://msdn.microsoft.com/en-us/library/aa214068%28v=sql.80%29.aspx

    Views are not automatically cached.

    When you SELECT from a view, the database has to run the query stored in the view to get the result set to use in your statement

    The data you 'see' in a view, is not actually stored anywhere, and is generated from the tables on the fly.

    Because of this be careful running views which are very complex. Always take into account that the view will have to be executed before its result set is accessed.

提交回复
热议问题