January 11, 2019 at 4:51 am
How we can refresh the view?
January 11, 2019 at 5:08 am
Hi
every time you select something from a view, it is fresh.
The sql server ist able to create a "static" view:
https://docs.microsoft.com/en-us/sql/relational-databases/views/create-indexed-views?view=sql-server-2017
The the default view is created every time you select something.
Kind regards,
Andreas
January 11, 2019 at 6:22 am
Except for materialized views (more on that in a moment), a view is just a query. Yes, it looks and acts like it's a table. It's not. It's just a query. It's a convenient way to mask or format data within a query that can then be consumed as if it was a table. However, it's always just a query. So, there's nothing to refresh. Just as running SELECT * FROM Table doesn't require any special magic to get the data, so SELECT * FROM View does not either.
Now, a materialized view, or an indexed view, is different. In this case you've taken what was just a query and turned it into a clustered index, a new table. However, even that is updated regularly as the data in the original underlying tables gets updated. No need to do a special refresh. They do have a bunch of special requirements which prevents them from being used in some situations, but you can read about that in the documentation.
This is different behavior than a materialized view in Oracle. Maybe that's what you're thinking about.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
January 15, 2019 at 12:25 am
We can use SQL CREATE and REPLACE for refreshing the view.
Syntax:
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply