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

Oracle触发器

--创建触发器(行级触发器)
create or replace trigger tri_update_emp_bak
after update
on emp_bak
for each row --每更新一行 就触发一次
begin
--oracle 里面 对触发器 也提供了特殊的对象 :NEW :OLD 来访问 更新前后的数据

dbms_output.put_line('更新后' || :NEW.sal);
dbms_output.put_line('更新前' || :OLD.sal);

if updating then

end if;

if inserting
end;
--创建触发器(行级触发器)(前置)
create or replace trigger tri3_update_emp_bak
before update
on emp_bak
for each row --每更新一行 就触发一次
begin
--oracle 里面 对触发器 也提供了特殊的对象 :NEW :OLD 来访问 更新前后的数据

dbms_output.put_line('更新后' || :NEW.sal);
dbms_output.put_line('更新前' || :OLD.sal);
end;
select * from emp_bak
update emp_bak set sal = 1000 where empno in (7788)
--创建触发器(表级触发器)
--//表级别触发器里面 不允许使用 :NEW :OLD 变量
create or replace trigger tri2_update_emp_bak
after update
on emp_bak
begin

-- dbms_output.put_line('更新后' || :NEW.sal);
--dbms_output.put_line('更新前' || :OLD.sal);
end;
--创建触发器(行级触发器)
create or replace trigger tri4_update_emp_bak
after update of sal
on emp_bak
for each row --每更新一行 就触发一次
begin
--oracle 里面 对触发器 也提供了特殊的对象 :NEW :OLD 来访问 更新前后的数据

dbms_output.put_line('更新后' || :NEW.sal);
dbms_output.put_line('更新前' || :OLD.sal);
end;
create table userinfo
(
userid number(4) primary key,
username varchar2(20)
)
create table addrinfo
(
addrid number(4) primary key,
addname varchar2(20),
userid number(4) references userinfo(userid)
)
insert into userinfo values (1,'李四')
insert into addrinfo values (1,'湖北武汉',1)
select * from addrinfo
delete from userinfo where userid =1
--级联删除
create or replace trigger tri_userinfo_delete
before delete
on userinfo
for each row
begin
del


相关文档:

【转帖】SQL Oracle删除重复记录

1.Oracle删除重复记录.
删除表中多余的重复记录,重复记录是根据单个字段(peopleId)来判断,只留有rowid最小的记录.
delete from people
where peopleId  in (select  peopleId  from people  group  by  peopleId   having  count(peopleId) > 1)
and rowid not i ......

oracle LogMiner简介

原文地址:http://www.phontol.com/20090719_525808_1.html
1  LogMiner 的用途
  Oracle LogMiner 是 Oracle公司从产品 8i以后提供的一个实际非常有用的分析工具,使用该工具可以轻松获得 Oracle重作日志文件(归档日志文件)中的具体内容,特别是,该 工具可以分析出所有对于数据库操作的 DML(insert、update、 ......

ORACLE 通过游标使用来了解cursor 的好处!

有了游标,就可以不用每条数据去检查是否符合条件,先看一下下面的:
--游标使用(游标其实是一个放入内存临时表)
declare
   money cms3_simcard.card_fee%type :=0; --定义与表字段相同类型
   cursor mycursor is --定义游标
          select ......

oracle 中的exception

  1、异常的优点
  
  如果没有异常,在程序中,应当检查每个命令的成功还是失败,如
  BEGIN
  SELECT ...
  -- check for ’no data found’ error
  SELECT ...
  -- check for ’no data found’ error
  SELECT ...
  -- check for ’no data found’ err ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号