create or replace view vm_emp as select * from emp; create or replace view vm_emp as select deptno, empno, ename from emp where deptno=10; -- or replace代表如果视图存在,就替换 --查看视图 select view_name from user_views;
添加创建视图权限
1 2 3 4 5
添加步骤: 1. 使用管理员登陆:sqlplus / as sysdba 2. 给scott用户增加权限: SQL> grant create view to scott; 3. 执行“/”可成功创建视图empincomeview。 4. 视图的操作和表的操作完全一样。 SQL> select * from empincomeview;
3 如何删除视图
1 2
drop view 视图名; drop view vm_emp;
4 使用视图的优点:
可以限制用户对某些数据的访问;
可以简化查询;
5 使用视图注意点:
不要通过视图去修改表的数据.
可以将视图设置为只读属性:with read only
1
create or replace view vm_emp as select * from emp with read only;