Thursday, November 18, 2010

Interview Question's Answer : SQL Server View

Question: What is View?
Answer: View is collection of one or more related tables. It’s getting the selected columns which are required from different tables in to one table. View is a de normalized representation data.
Types of View:
1.       Normal View
2.       Indexed Views

Question: What is Normal View?

Answer: Normal views are like the virtual tables. There is no physically existence for them in the database. It’s just like select statement which is stored in database.
Syntax for create normal view

Create view sample1
as
select [tab1.column1],
       [tab2.column2],
       ...
       .
       .
from
tab1
inner join tab2 on tab1.col=tab2.col
inner join ....

Question: What is Indexed View?
Answer: Index views are the views on which index can be created. These views exist physically in the database. This view created with clause schema binding.

Question: How to Refresh Index View:
Answer
: Index view got refresh automatically when there is any refresh in the data in the tables which are used in view creation.
Create view sample2 with schemabinding
as
select [tab1.column1],
       [tab2.column2],
       ...
       .
       .
from
tab1
inner join tab2 on tab1.col=tab2.col
inner join ....

No comments:

Post a Comment