oracle 相关笔记

1.查询语句执行顺序 from->where->[group by ]-> select ->distinct->count(某一列)
2.用命令执行存储过程用 exec 或 begin and /
3.oracle 定义变量, declare 关键字来定义。 定义常量,用constant, 也可以%type 来定义,%rowtype来定义。
4.oracle 常用函数:https://www.cnblogs.com/chuangege/p/6258658.html

5.oracle的if判断 if then elsif then else end if case when end case;
6.oracle的循环: 1种:loop end loop; 2种: while loop end loop
3种: for v_i *** in reverse 1 .. 3 loop end loop 倒序遍历

for v_i *** in 1 .. 3 loop end loop;

7.oracle 中 编译时异常无法捕获。sqlcode 获取异常代码 sqlerrm 获取异常错误信息
8.oracle 中 定义记录类型 type *** is record(.....);


9.oracle 中定义记录类型例子:
declare
type fpagent_type is record(

agentid fpagent.agentid%type,
agentjid fpagent.agentjid%type,
name fpagent.name%type,
maxchats fpagent.maxchats%type,
minchats fpagent.minchats%type

);
v_fpagent fpagent_type;
v_agentid number := &agentid;
begin
select * into v_fpagent from fpagent where agentid=v_agentid;

dbms_output.put_line('agentid:'||v_fpagent.agentid);
dbms_output.put_line('agentjid:'||v_fpagent.agentjid);
dbms_output.put_line('name:'||v_fpagent.name);
dbms_output.put_line('maxchats:'||v_fpagent.maxchats);
dbms_output.put_line('minchats:'||v_fpagent.minchats);


end;
/

注意:select 出来的字段顺序要与type定义的顺序一致。


10.oracle 索引表:


例子:


11.commit事物以后,不能用rollback回滚 如果要找回的话 可以用闪回

12.我们所用到的表都存放到Users表空间里。

原文地址:https://www.cnblogs.com/lipengsheng-javaweb/p/11441785.html