標籤:style blog color 使用 for div ar 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 rowdeclare -- local variables herebegin 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;