SQL实现触发器
发布网友
发布时间:2022-04-07 23:02
我来回答
共1个回答
热心网友
时间:2022-04-08 00:31
--(1)
create trigger trigCourseInserton on Course for insert as
print '你正在插入课程信息'
go
--(2)
create trigger trigCourseUpdate on course for update as
declare @YKC as varchar(10)=(select Cname from deleted)
declare @XKC as varchar(10)=(select Cname from inserted)
print '原课程:'+@YKC+' 新课程:'+@XKC
go
--(3)
create trigger trigStudentDelete on Student for delete as
insert into 毕业生表 select * from deleted
go
--(4)
create trigger triSCInsert on SC instead of insert as
if not exists(select * from Course join inserted on Course.Cno=inserted.Cno)
begin
print '课程表中没有改课程!'
rollback
end
追问谢谢