View : To restrict the columns access within a schema we use view.
Types of view :
SQL>Create view employee_v as select name,no,dno from employee;
Note :
Complex view :
Example:Types of view :
- Simple view
- Complex view
- Materialized view
- View created based on Single table is called simple view.
- We can perform DML operations on view.
- Changes made to view data will be reflected on original table.
- view doesn't store data.
SQL>Create view employee_v as select name,no,dno from employee;
Note :
- create view in one schema .
- grant privileges on that view to another schema user.
Complex view :
- When multiple tables participates in creation of view it is called complex view .
- Joins are used.
- DML operations can't be performed.
SQL> create view employee_v as (select a.name,a.no,a.dno,b.dname from employee a,department b where a.dno=b.dno);
Note : view is an object which has to be access from one schema to another . So again grant privileges are required.
Materialized view :
- Is a database object
- Advantages over normal and complex views.
- Always used in real time for reporting.
SQL>materialized view employee_mv complete refresh based on primary key start with sysdate next sysdate +1 as select name,no from emp;
Difference between view and materialized view:
View :
- Has logical existence.
- Changes reflected to original table.
- Cant perform DML operations on complex view
- As view always called then it calls the sub query which takes response time.
- Has physical existence.
- Changes not reflected to original table.
- Can perform DML operations on it.
- Can perform auto refreshing on materialized view. on schedule basis.
- performance is better.
0 comments:
Post a Comment