简单入门的Oracle触发器使用

--建表语句
create table student(id number(9),name varchar2(64),age number(5));create table class(id number(9),name varchar2(64),teacherid number(9),studentid number(9));create table teacher(id number(9),name varchar2(64),age number(5)); --学生信息 insert into student values(1,yangml,23); insert into student values(2,zhangj,23); insert into student values(3,zhulj,26); insert into student values(4,chenglp,26); --老师信息 insert into teacher values(1,yangls,33); insert into teacher values(2,zhangls,33); insert into teacher values(3,zhuls,33); insert into teacher values(4,chenls,33); --班级信息 insert into class values(1,一年级,1,1); insert into class values(2,二年级,2,2); insert into class values(3,三年级,3,3); insert into class values(4,四年级,4,4); --删除触发器 create or replace trigger trigdel before delete on class for each row declare -- local variables here begin delete from teacher where teacher.id=:old.id; delete from student where student.id=:old.id; end trigdel; --测试删除 delete from class; select * from class; select * from student; select * from teacher;

 

简单入门的Oracle触发器使用,布布扣,bubuko.com

简单入门的Oracle触发器使用

上一篇:用mapreduce实现将mysql数据导出到HDFS上


下一篇:C#访问PostGreSQL数据库的方法 http://www.jb51.net/article/35643.htm