oracle数据库例外处理与视图
2016-09-17 20:12
555 查看
pl/sql例外处理
例 当输入编号没有时的例外处理
--自定义例外
oracle视图
视图是一个虚拟表,其内容由查询定义,同真实的表一样,视图包含一系列带有名称的列和行数据,但是,视图并不在
数据库中以存储的数据值集形式存在,行和列数据来自由定义视图的查询所引用的表,并且在引用视图时动态生成。
表需要占用磁盘空间,视图不需要
视图不能添加索引
使用视图可以简化复杂查询
例 当输入编号没有时的例外处理
declare --定义 v_ename emp.ename%type; begin -- select ename into v_ename from emp where empno = &gno; dbms.output.put_line('名字:'||v_ename); exception when no_data_found then dbms_output.put_line('编号没有!'); end;
--自定义例外
create or replace procedure ex_test(spNo number) is --定义例外 myexcep exception; begin --更新 update emp set sal = sal + 1000 where empno = spNo; --sql%notfound这是表示没有update --raise myexcep 触发myexcep if sql%notfound then raise myexcep; end if; exception when myexcep then dbms_output.put_line('没有update'); end;
oracle视图
视图是一个虚拟表,其内容由查询定义,同真实的表一样,视图包含一系列带有名称的列和行数据,但是,视图并不在
数据库中以存储的数据值集形式存在,行和列数据来自由定义视图的查询所引用的表,并且在引用视图时动态生成。
表需要占用磁盘空间,视图不需要
视图不能添加索引
使用视图可以简化复杂查询
创建视图 create view myview as select * from emp where sal<1000; 使用视图 select * from myview; 利用视图简化操作 create view myview2 as select emp.deptno,emp.name,dept.deptno from emp,dept where emp.deptno = dept.deptno; select * from myview2;
相关文章推荐
- ORACLE中ESCAPE关键字用法
- oracle where 与having 的区别
- win 8 64位 下安装oracle 提示 ins-13001 环境不满足最低要求的解决办法(亲测)
- Oracle 11g数据库的部署
- Oracle存储过程、存储函数
- 在Oracle中查询Date类型字段的数据
- Oracle知识点(2)简单查询 模糊查询 范围查询
- 数据库Oracle 9i 的保护模式
- ORA-12514 TNS 监听程序当前无法识别连接描述符中请求服务 的解决方法
- 查看表的建表语
- oracle 职业学习指引
- CentOS7 Mini安装Oracle后用PL/SQL连接数据库(图形化安装)
- Oracle 查询优化改写
- oracle的时间处理
- Oracle知识点巩固 (安装与卸载)和cmd命令
- ORACLE sql语法的表示问题
- EntityFrameWork连接Oracle错误总结
- oracle如何使用java source调用外部程序
- 【解决办法】Oracle 10g完美卸载重装
- 【解决办法】Oracle登录报错ORA-28000: the account is locked