前端之家收集整理的这篇文章主要介绍了
Oracle-view小结,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
@H_
502_0@
/*
create view empview2
as
select employee_id,last_name,salary
from employees
where department_id =
80
*/
/*
create
or replace view empview2
as
select employee_id,salary
from employees
where department_id =
80
*/
/*
create
or replace view empview3
as
select department_name,avg(salary) avg_sal
from employees e,departments d
where e.department_id = d.department_id group
by department_name
*/
drop view empview3
/*
create view empview4
as
select employee_id,salary
from employees
where department_id =
80
with read only
*/
update empview4
set salary =
1200 where employee_id =
179;
delete
from empview4
where employee_id =
179;
PS:视图中使用DML的规定
1.当视图定义中包含以下元素之一时不能使用insert:
组函数;group by 子句;distinct 关键字;rownum 伪列;列的定义为表达式;表中非空的列在视图定义中未包括。
2.当视图定义中包含以下元素之一时不能使用update:
group by 子句;distinct 关键字;rownum伪列;列的定义为表达式;
3.当视图定义中包含以下元素之一时不能使用update:
组函数;group by 子句;distinct 关键字;rownum 伪列。