Oracle视图
来源:互联网 发布:qq mac版手机 编辑:程序博客网 时间:2024/06/05 22:35
Oracle视图
基本介绍
视图是一个虚拟表,其内容由查询定义。同真实的表一样,视图包含一系列带有名称的列和行数据。但是,视图并不在数据库中以存储的数据值形式存在。行和列数据来自由定义视图的查询所引用的表,并且在引用视图时动态生成。
视图是oracle又一种数据对象,视图的主要的用处是简化操作,提高效率,满足不同用户的查询需求,视图不是一个真正存在的物理表,它是根据别的表动态生成的。
创建视图基本语法:
create view 视图名 as select语句 [with read only]
特别说明:with read only如果带上的话,只能查询,不能改写。
创建或修改视图基本语法:
create or replace view 视图名 as select语句 [with read only]
特别说明:with read only如果带上的话,只能查询,不能改写。
删除视图基本语法:
drop view 视图名;
实例:
--视图--创建一个emp2的视图,包含(empno,ename,sal)create or replace view emp_view1 as select empno,ename,sal from emp2;--使用视图查询select * from emp_view1;--使用视图修改update emp_view1 set sal = 1500 where empno='7369';--创建一个emp2的视图,包含(empno,ename,sal),只能读取不能进行其他操作create or replace view emp_view2 as select empno,ename,sal from emp2 with read only;--使用视图查询select * from emp_view2;--查询员工的名字和部门编号和部门名称create or replace view emp_view3 as select e.ename,d.deptno,d.dname from emp2 e,dept2 d where e.deptno = d.deptno with read only; --使用视图查询select * from emp_view3;
注意:
当表结构过于复杂时,请使用视图。
视图可以简化操作(可以将多表中的字段合并在一张视图中)
视图与表的区别
1、表需要占用磁盘空间,而视图不需要;
2、视图不能添加索引;
3、使用视图可以简化复杂查询;
4、使用视图利于提高安全性。
----------参考《韩顺平玩转Oracle》
0 0
- oracle视图
- oracle视图
- Oracle视图
- Oracle视图
- Oracle视图
- Oracle视图
- oracle视图
- Oracle 视图
- oracle 视图
- oracle视图
- oracle视图
- oracle 视图
- oracle 视图
- Oracle视图
- Oracle视图
- oracle 视图
- oracle视图
- oracle 视图
- macpro 装Ubuntu15 虚拟机 字太小的调节方法
- 检测文件中是否存在bom
- XSS攻击测试语句
- LeetCode OJ 系列之1 Two Sum --Python
- Android Studio Tips-倍数提高工作效率的Android Studio奇技
- Oracle视图
- 基于JQUERY的WEB在线流程图设计器GOOFLOW 0.5版
- Android 键盘使用一(监听弹出隐藏)
- LeetCode OJ 系列之62 Unique Paths --Python
- 一些系统漏洞
- 打包输出文件太大
- 数据结构 — 树 与 二叉树、森林
- 关于“一秒一G LiFi比WiFi快一百倍”的评论
- 项目适配iOS9遇到的一些问题及解决办法