Presentation is loading. Please wait.

Presentation is loading. Please wait.

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.

Similar presentations


Presentation on theme: "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."— Presentation transcript:

1 Views

2 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 as Select, ……. from where = ; 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 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 Namecreate 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 )


Download ppt "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."

Similar presentations


Ads by Google