视图
-- 什么是视图:视图是逻辑上来自一个或多个表的数据集合。
-- 视图是虚拟的,不真实存在
-- 限制其它用户对数据库表的访问,因为视图可以有选择性的显示数据库表的一部分;
-- 容易实现复杂的查询;
-- 对于相同的数据可以产生不同的视图;
-- 视图的操作和表一样
-- 简单的视图:数据来至于一张表
-- 创建视图 :该视图只显示20号部门的员工信息
create or replace view emp_v_deptno20 as select * from emp where deptno=20;
-- 访问视图
select * from emp_v_deptno20;
创建一个视图,通过该视图可以查询到工资在2000-5000内并且姓名中包含有A的员工编号,姓名,工资。
create or replace view emp_v_sal_ename as select empno,ename,sal from emp where (sal between 2000 and 5000) and 0<instr(ename,'A')
select ename from emp_v_sal_ename;
-- 给视图的列名起列别名
create or