Thursday, March 10, 2016

WHAT IS VIEW? TYPES OF VIEWS?


WHAT IS VIEW?

 View is nothing but parsed SQL statement which fetches record at the time of execution.


TYPES OF VIEWS?

There are mainly two type of views
a) Simple View
b) Complex View
apart from that we can also subdivided views as UpdatableViews and Read only Views.
Lastly there is an another view named as Materialized Views.


PURPOSE OF VIEWS

View is used for the purposes as stated below:
a) Security
b) Faster Response
c) Complex Query solve



Syntax is :


Create or replace view([olumn1],[column2]...)
as
Select column1,column2...
from table_name
[where condition]
[with read only],[with check option]


What is Materialized View ?

Materialized views are also logical view of our data driven by select query but the result of the query will get stored in the table or disk, also definition of the query will also store in the database .When we see the performance of Materialized view it is better than normal View because the data of materialized view will stored in table and table may be indexed so faster for joining also joining is done at the time of materialized views refresh time so no need to every time fire join statement as in case of view.

Difference between View vs Materialized View in database


Based upon on our understanding of View and Materialized View, Let’s see, some short difference between them :

1) First difference between View and materialized view is that, In Views query result is not stored in the disk or database but Materialized view allow to store query result in disk or table.

2) Another difference between View vs materialized view is that, when we create view using any table,  row id of view is same as original table but in case of Materialized view row id is different.

3) One more difference between View and materialized view in database is that, In case of View we always get latest data but in case of Materialized view we need to refresh the view for getting latest data.

4) Performance of View is less than Materialized view.

5) This is continuation of first difference between View and Materialized View, In case of view its only the logical view of table no separate copy of table but in case of Materialized view we get physically separate copy of table

6) Last difference between View vs Materialized View is that, In case of Materialized view we need extra trigger or some automatic method so that we can keep MV refreshed, this is not required for views in database.

No comments:

Post a Comment