北大青鸟oracle学习笔记26 27 28
数据库触发器
触发器语句
制定触发器定时、事件、表名及类型
触发器主体
是pl/sql快或对过程的调用
触发器限制
可以通过when子句实现
DML(insert update delete)
DDL(create alter drop)
数据库操作(servererror logon logoff startup shutdown)
create trigger 触发器名
before|after insert|delete|update of 列名
on 表名
[for each row] --行级触发器
when 条件
触发器谓词
inserting insert操作
updating update操作
deleting delete操作
可以根据这三个谓词判断到底在执行哪个操作
create or replace
Trigger tg_insert
before insert or update on student
for each row
begin
if updating then
dbms_output.put_line('before update');
end if;
if inserting then
dbms_output.put_line('before insert');
end if;
end;
触发器类型:
1、 表级触发器(表级触发器对每个DML语句执行一次)
create or replace Trigger tg_insert
before update on student
begin
dbms_output.put_line('before update);
end;
4 rows updated
before update
2、 行触发器 (行级触发器对DML语句影响的每个行执行一次)
create or replace
Trigger tg_insert
before update on student
for each row --每行触发一次
begin
dbms_output.put_line('before update');
end;
4 rows updated
before update
before update
before update
before update
使用触发器时,两个特殊值:new 新插入的值 :old 原来的值 不能用于表级触发器
create or replace trigger trig_job
before insert or update of job
on emp
for each row
begin
if inserting then
:new.job:=upper(:new.job);
else
:new.job:=upper(:new.job);
end if;
end;
3、INSTEAD OF触发(此触发器是在视图上而不是在表上定义的触发器,它是用来替
相关文档:
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 ......
俩台不同的数据库服务器,从一台数据库服务器的一个用户读取另一台数据库服务器下的某个用户的数据,这个时候可以使用dblink。
其实dblink和数据库中的view差不多,建dblink的时候需要知道待读取数据库的ip地址,ssid以及数据库用户名和密码。
创建可以 ......
1. 在打开Enterprise Manager Consol时报错: "找不到目标主机";
【解决方案】该问题在使用Ghost制作的系统中常见, 出错原因是Oracle中配置的主机名
和实际的主机名不一致. 解决方法如下:
(1) Enterprise Manager Consol -> 工具菜单 ->服务管理 -> Oracle Net Manager;
(2) 将"本地 ......
【实现步骤】
1. 创建表blog_info, 具有ID和title两个字段, 其中ID将设置为自动增长列;
2. 创建序列:
create sequence sq_blog_info
start with 1
increment by 1
nomaxvalue
nocycle
......
1) 用SELECT语句从表中提取查询数据。语法为
SELECT [DISTINCT] {column1,column2,…} from tablename WHERE {conditions} GROUP BY {conditions} ORDER BY {expressions} [ASC/DESC];
说明:SELECT子句用于指定检索数据库的中哪些列,from子句用于指定从哪一个表或视图中检索数据。
2) ......