MSSQL:
首先你的学号在sc的外键必须是 on delete cascade
alter table sc
add constraint fk_test foreign key (学号) references s(学号) on delete cascade
create trigger test on s
after delete
as
begin
delete from sc where 学号 in (select 学号 from deleted)
end
Oracle:
create or replace trigger test
after delete on s
for each row
begin
delete from sc where 学号=:old.学号;
end;
扩展资料:
SQL语法
DELIMITER |
CREATE TRIGGER `<databaseName>`.`<triggerName>`
< [ BEFORE | AFTER ] > < [ INSERT | UPDATE | DELETE ] >
ON [dbo]<tableName> //dbo代表该表的所有者
FOR EACH ROW
BEGIN
--do something
END |
参考资料来源:百度百科-触发器
创建触发器:当删除学生表S中的一条学生记录时,自动删除选修表SC中该...
首先你的学号在sc的外键必须是 on delete cascade alter table sc add constraint fk_test foreign key (学号) references s(学号) on delete cascade create trigger test on s after delete as begin delete from sc where 学号 in (select 学号 from deleted)end Oracle:create or replace trigge...
创建一个触发器,当删除一个学生信息时,删除成绩表中所有有关该学生的...
StudentCJ表:StudentID,StudentCJ 触发器:CREATE TRIGGER [Delete_student] ON [dbo].[Student]FOR DELETE AS begin declare @StudentID int select @StudentID=StudentID from deleted delete from StudentCJ where StudentID=@StudentID end 有问题可以追问或Hi我。
在student表上创建触发器del_trg,当删除表中某一个学生的记录时,能自...
UPDATE sc SET sc.学号=:new.学号 where sc.学号=:old.学号;end del_trg;
...创建一触发器,删除学生表的记录同时也删除成绩表中的相关记录_百度...
create or replace trigger tr1 before delete on XSB for each row begin delete from CJB where CJB.xh=:old.xh;end;\/
SQL 2008 怎么实现删除学生表里面的一条记录,成绩表里面关于这个学生的...
-- 按照注释一步步执行 看效果--创建表IF OBJECT_ID('tstudent') > 0 DROP TABLE tstudentGO CREATE TABLE tstudent ( fstudentno VARCHAR(10) PRIMARY KEY , fname NVARCHAR(10), )IF OBJECT_ID('tScore') > 0 DROP TABLE tScoreCREATE TABLE tScore ( fstudent...
...一个触发器tri_del 当删除了studinfo表中的某学生后,自动删...
CREATE TRIGGER tri_del AFTER DELETE ON studinfo FOR EACH ROW BEGIN delete from studscoreinfo where studscoreinfo.id=studinfo.id;\/\/where条件根据表关系自己修改 END;
SQL创建触发器trigger1,实现当修改学生信息表中的某个学生的学号时,对...
create trigger trigger1 on 学生信息表for updatedeclare @old_id intdeclare @new_id intselect @old_id=学号 from deletedselect @new_id=学号 from insertedif update(学号)beginupdate 学生成绩表 set 学号=@new_id where 学号=@old_idend你运行下,应该没有问题。如果你的学号不是int类型,...
...的触发器,当向学生表student中插入记录时,自动更新班级表class中...
1、首先打开sqlyog并和mysql建立连接。2、在sqlyog软件左侧树形菜单中要到触发器选项。3、在触发器选项上点击右键找到创建触发器选项,或者选择触发器选项按f4也可以弹出创建触发器弹窗。4、想要创建一个名称为trigger的触发器,那么就在弹窗的输入框中输入trigger并点击确定即可。5、想要创建一个biao1中...
...触发器,当用户成功删除该表中的一条或多条记录时,触发器自动删除S...
if exists (select name from sysobjects where name='mytring' and type='tr')drop trigger mytring go create trigger mytring on class for delete as delete from score ,record where class.姓名 in(select class.姓名 from deleted)go ...
如何删除表触发器如何删除表触发器里的数据
创建触发器:当删除学生表S中的一条学生记录时,自动删除选修表SC中该学生的成绩记录?MSSQL:首先你的学号在sc的外键必须是ondeletecascadealtertablescaddconstraintfk_testforeignkey(学号)referencess(学号)ondeletecascadecreatetriggertestonsafterdeleteasbegindeletefromscwhere学号in(select学号fromdeleted)...