1 / 11

Views

Views. Views. Logical data is how we want to see the current data in our database . Physical data is how this data is actually placed in our database. Views may be created for the following reasons :-. Provides data security Simplifies queries Can be queried as a table itself .

neith
Download Presentation

Views

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Views

  2. Views • Logical data is how we want to see the current data in our database. • Physical data is how this data is actually placed in our database.

  3. Views may be created for the following reasons :- • Provides data security • Simplifies queries • Can be queried as a table itself. • Avoids data redundancy. • Prevents updating a record as DBA knows you are really working with a subset of a record.

  4. Creation of views Syntax Create view <Viewname> as Select <columnname1>, <columnname2> ……. from <tablename> where <column name> = <expression liat>; Example SQL> Create view emp_view as select eno, ename, salary from emp where salary>=5000;

  5. Rename the columns of a view SQL> create view emp_view as select eno,ename,salary, dno from emp where eno between 10 and 100; (give existing view name )

  6. Update table join views SQL> Create view ex_v1 as select emp.eno, emp.ename, emp.dno, dept.dname from emp,dept where dept.dno=emp.dno;

  7. Destroying a view Syntax Drop view <viewname> Example SQL> drop view emp_xx;

  8. Example SQL>create view v1 as select * from emp; SQL>create view v1 (emp_name,salary) as select ename, salary from emp; SQL> Select * from user_views;

  9. Check option • Std Rollno Name create table Sub1 Sub2 Sub3 SQL> Create view std_best as select rollno,name,sub1,sub2,sub3 from std where sub3>=90 with check option;

  10. Update option SQL> Create view v2 (eno,ename,salry) as select eno,ename, salary*2 from emp; SQL> select * from v2; SQL>create view v3 (deptno, salary) as select dno,sum(salary) from emp group by dno;

  11. SQL> Create view h1 as select ename, salary from emp where salary>=5000 with check option; SQL> insert into h1 values (‘ram’,7000); SQL> insert into h1 values (‘ravi’,3000); (Not insert )

More Related