Oracle学习笔记摘录6
declare
begin
--SQL语句
--直接写的SQL语句(DML/TCL)
--间接写execute immediate <DDL/DCL命令字符串>
--select 语句
<1>必须带有into子句
select empno into eno from emp
where empno =7369;
<2>只能查到一行**********
<3>字段个数必须和变量的个数一致
exception
--异常
when <异常名字> then --特定异常
<处理语句>
when others then --所有异常都可捕获
<处理语句>
end;
<例子>
编写程序 向DEPT表中插入一条记录,
从键盘输入数据,如果
数据类型输入错误要有提示
无法插入记录 也要有提示
只能输入正数,如果有负数提示
declare
n number;
no dept.deptno%type;
nm dept.dname%type;
lc dept.loc%type;
exp exception; --异常的变量
exp1 exception;
num number:=0; --计数器
pragma exception_init(exp,-1); --预定义语句
--(-1错误和异常变量关联)
pragma exception_init(exp1,-1476);
e1 exception; --自定义异常变量
begin
--输入值
no := '&编号';
num := num + 1;
if no < 0 then
raise e1; --自定义异常的引发
&
相关文档:
oracle 方法 & ......
for example:
15:18:59 SQL> create table t1 (a int, b int);
表已创建。
已用时间: 00: 00: 00.15
......
一、在PLSQL中创建表:
create table HWQY.TEST
(
CARNO VARCHAR2(30),
CARINFOID NUMBER
)
二、在PLSQL中创建存储过程:
create or replace procedure pro_test
AS
carinfo_id number;
BEGIN
select s_CarInfoID.nextval into carinfo_id
from dual;
insert into test(test ......
1.更改归档路径
在ORACLE10G中,默认的归档路径为$ORACLE_BASE/flash_recovery_area。对于这个路径,
ORACLE有一个限制,就是默认只能有2G的空间给归档日志使用,可以使用下面两个SQL语句去查看它的限制
1. select * from v$recovery_file_dest;
sql >show parameter db_recovery_file_dest(这个更友好直观一些)
当 ......
说到软解析(soft prase)和硬解析(hard prase),就不能不说一下Oracle对sql的处理过程。当你发出一条sql语句交付Oracle,在执行和获取结果前,Oracle对此sql将进行几个步骤的处理过程:
1、语法检查(syntax check)
检查此sql的拼写是否语 ......