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 I add records to either of them?
Will these new records show up in the VIEW
?
yes it is possible to insert,Update and delete using views. Mostly it is used to show limited data to user not whole table. View is nothing but an interface between Original table and user. yes it is possible to insert,Update and delete using views.
Yes , View gets updated. Please note that View is a logical statement and the data in view is not stored anywhere, the data is returned from database every time we select data from view.
Views need to be refreshed if the underlying tables change at all. That can change the datatypes of the view's columns or rearrange its indexes.
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.
A view is basically a stored query, it holds no data so no, it won't get updated when the tables it's built on are. However as soon as you reference the view the query it's based on will run, so you will see the changes made to the base tables.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With