Friday, May 2, 2014

View & Materialized View & Inline View

View:

Why Use Views?
• To restrict data access
• To make complex queries easy
• To provide data independence
  A simple view is one that:
– Derives data from only one table
– Contains no functions or groups of data
– Can perform DML operations through the view.

 A complex view is one that:
– Derives data from many tables
– Contains functions or groups of data
– Does not always allow DML operations through the view
 
 
A view has a logical existence but a materialized view has 
a physical existence.Moreover a materialized view can be 
Indexed, analysed and so on....that is all the things that 
we can do with a table can also be done with a materialized 
view.
 
We can keep aggregated data into materialized view. we can schedule the MV to refresh but table can’t.MV can be created based on multiple tables.
 

Materialized View:

 
In DWH materialized views are very essential because in reporting side if we do aggregate calculations as per the business requirement report performance would be de graded. So to improve report performance rather than doing report calculations and joins at reporting side if we put same logic in the MV then we can directly select the data from MV without any joins and aggregations. We can also schedule MV (Materialize View).

Inline view:

If we write a select statement in from clause that is nothing but inline view.
 
Ex:
Get dept wise max sal along with empname and emp no.
 
Select a.empname, a.empno, b.sal, b.deptno 
From EMP a, (Select max (sal) sal, deptno from EMP group by deptno) b
Where
a.sal=b.sal and

a.deptno=b.deptno

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.