易截截图软件、单文件、免安装、纯绿色、仅160KB

北大青鸟oracle学习笔记25

过程中的事务
定义过程p1
create or replace procedure p1
as
begin
insert into student values(5,'xdh','m',sysdate);
rollback;
end;
定义过程p2
create or replace procedure p2
as
begin
update student set stu_sex = 'a' where stu_id = 3;
p1;
end;
执行过程p2

exec p2;
执行完毕发现表中数据没有变更,说明p1中的rollback语句将p2中的update语句也回滚了。
自主事务处理
步骤:

主事务处理启动自主事务处理

主事务处理被暂停

自主事务处理sql操作

中止自主事务处理

恢复主事务处理


pragma autonomous_transaction

用于标记子程序
在p1的as begin当中加入 pragma autonomous_transaction  后执行,发行p2的update语句生效,p1中的事务作为自主事务来处理,不影响主事务。
程序包
相关对象的封装

-程序包规格说明

    声明子程序,不包含实现

create package 包名 is|as 变量声明|类型定义|异常声明|游标声明|函数说明|过程说明

pragma restrict_references(函数名,WNDS[,WNPS][,RNDS][,RNPS])

end [包名];

create or replace package StuPackages

is

  type curRefStudent is REF CURSOR RETURN student%rowtype;

  procedure insertStudent(stuid in student.stu_id%type,stuname in student.stu_name%type,stusex in student.stu_sex%type,studate in student.stu_birthday%type);
Function QueryStudent(stuid in student.stu_id%type) return student%rowtype;
end StuPackages;

-程序包主体

    定义子程序,实现声明部分

create package body 包名 is|as 变量声明|类型定义|异常声明|游标声明|函数定义|过程定义

end [包名];
CREATE OR REPLACE
PACKAGE BODY STUPACKAGES AS
procedure insertStudent(stuid in student.stu_id%type,stuname in student.stu_name%type,stusex in student.stu_sex%type,studate in student.stu_birthday%type) AS
i INTEGER;
Student_Exist EXCEPTION;
BEGIN
select count(*) into i from student where stu_id = stuid;
if i>0 then
raise Student_Exist;
else
insert into student values(stuid,stuname,stusex,studate);
commit;
end if;


相关文档:

付首昕 ORACLE 10 学习笔记 第3课 命令。

ORACLE 10 学习笔记-第3课-命令。
1.view 限制
create or replace view my_view01
as select * from emp
with check option
/
2.synonym 同义词
create synonym dept for scott.dept;
select * from dept;
3.sysdba 公共
drop synonym dept;
create public synonym dept for scott.dept;
desc dba_synonyms
......

oracle 表结构的修改

oracle 表结构的修改
今天总结下关于表的修改,防止以后忘记,好记性不如烂笔头吗!!!
更改表的结构
1.编辑表的字段
  修改一个列的数据类型(一般限于修改长度,修改为一个不同类型时有诸多限制):
  语法:
    ALTER TABLE 表名 MODIFY(列名 数据类型);
 eg1:
   alter table ......

ORACLE RAC DOWN机问题分析

Author: Rainny
Date: 2010-3-5
一,症状描述
2个节点的ORACLE 10G RAC,隔一段时间其中的一个NODE就会DOWN机。节点从CLUSTER中被驱逐。
二,诊断过程
Rac1被逐出,RAC2存活,RAC2接管了RAC1的VIP,我们来查看RAC2的相关LOG。
首先查看RAC2的告警日志:..\log\rac2\alertrac2.log:
2010-03-05 14:39:50.750
[cssd(7 ......

oracle表分区详解


http://tianzt.blog.51cto.com/459544/171759   仅仅供自己学习之用
此文从以下几个方面来整理关于分区表的概念及操作:
        1.表空间及分区表的概念
        2.表分区的具体作用
        3 ......

在Oracle中设置自动增长列


【实现步骤】
 1. 创建表blog_info, 具有ID和title两个字段, 其中ID将设置为自动增长列;
 2. 创建序列:
    create sequence sq_blog_info
    start with 1
    increment by 1
    nomaxvalue
    nocycle
   ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号