トリガーの使用

6280 ワード

oracle下
--          
--              stri_stu 
create trigger stri_stu --on              ( :on stu   stu     ) --afterinsert delete update ) --as            --begin --declare     (  :declare @temp int   int   @temp) --sql   --end    -------------------------------   (    ) create trigger tri_stu on stu after delete as begin declare @temp int select @temp = id from deleted delete from course where id = @temp /*if(delete from stu where id='1') then(delete from course where id='1')*/ end select * from stu select * from course delete from stu where id = 1 -------------------------------   (    ) --drop trigger tri_student create trigger tri_student on stu after insert as begin declare @temp int select @temp = id from inserted insert into course (id,cno) values (@temp,'003') --where id = @temp /*if(delete from stu where id='1') then(delete from course where id='1')*/ end select * from stu select * from course delete from stu where id = 1 insert into stu (id,name) values (1,'qwe')--where id =1 -------------------------------   (    )          --drop trigger student create trigger student on stu after update as begin declare @temp int --  int   declare @temp2 int --  int   select @temp=id from deleted --      select @temp2=id from inserted --      update course set id=@temp2 where id = @temp --   end update stu set id=10 where id=1 -----------------------------------              use tt go select * from sysobjects where xtype='TR' -----------------------------------        exec sp_helptext '    ' exec sp_helptext 'student' -----------------------------------      drop trigger