当前位置:网站首页 > 技术博客 > 正文

oracle 视图



--对简单视图的操作 drop table emp1; create table emp1 as select * from emp; --简单视图 create or replace view v_emp1 as select * from emp1 ; --查询 select * from v_emp1; --更新 update v_emp1 set v_emp1.ENAME='andy' where v_emp1.JOB='CLERK'; --增加 insert into v_emp1 values (7777, 'chy', 'MANAGER', 8888, sysdate, 10000,1111.11,20); --删除 delete from v_emp1 where v_emp1.EMPNO=7777; --复杂视图、仅两基表相连、不包含各种分组函数、group by、distinct命令等。 create or replace view v_complex as select emp1.ename, emp1.job, dept.dname from emp1, dept where emp1.deptno=dept.deptno with check option ; --查询 select * from v_complex; --修改 update v_complex set v_complex.ename='andy' where v_complex.job='MANAGER'; --增加 --报错:ORA-01776:无法通过连接视图修改多个基表 insert into v_complex (v_complex.ename, v_complex.job, v_complex.dname) values ('chy', 'MANAGER', 'SALES'); --删除 delete from v_complex where v_complex.ename='chy'; --复杂视图、包含不能进行DML的元素、一般仅用与查询、可以加上 with read only; create or replace view v_complex_readonly as --对使用聚合函数的列必须使用别名! select max(emp1.sal) max_sal from emp1, dept where emp1.deptno=dept.deptno group by dept.deptno with read only; --查询 select * from v_complex_readonly; --删除视图 create or replace view v_for_delete as select * from emp with read only; drop view v_for_delete;

版权声明


相关文章:

  • vc2010运行库官方下载2025-01-10 18:30:04
  • 求next数组值2025-01-10 18:30:04
  • o1bz线路22025-01-10 18:30:04
  • rsa加密算法java实现2025-01-10 18:30:04
  • easyn软件下载2025-01-10 18:30:04
  • oracle左连接和右连接的区别2025-01-10 18:30:04
  • open vswitch配置2025-01-10 18:30:04
  • 图像滤波的基本原理2025-01-10 18:30:04
  • java构造器实现原理2025-01-10 18:30:04
  • bat批处理命令复制文件2025-01-10 18:30:04