数据完整性:定义一个触发器,当删除Student表中数据时,先将删除的数据插入到另一个专门存放已删除的表中
定义一个触发器,当删除Student表中数据时,先将删除的数据插入到另一个专门存放已删除的表中(实验时,首先定义一个与Student表结构相同的表用来存放删除的数据),然...
定义一个触发器,当删除Student表中数据时,先将删除的数据插入到另一个专门存放已删除的表中(实验时,首先定义一个与Student表结构相同的表用来存放删除的数据),然后执行删除操作。
触发器代码: 展开
触发器代码: 展开
展开全部
假设定义的存放已删除数据的表叫stuback. 再假设student表里有这么几列:sno,sname,sage,ssex,sdep。
触发器代码:
create trigger stu on student
for delete
as begin
declare @sno char(10),@sname char(20),@sage char(2),@ssex char(20),
@sdep char(20)
select @sno=sno,@sname=sname,@sage=sage,@ssex=ssex,@sdep=sdep
from deleted
insert into stuback values(@sno,@sname,@sage,@ssex,@sdep)
end
触发器代码:
create trigger stu on student
for delete
as begin
declare @sno char(10),@sname char(20),@sage char(2),@ssex char(20),
@sdep char(20)
select @sno=sno,@sname=sname,@sage=sage,@ssex=ssex,@sdep=sdep
from deleted
insert into stuback values(@sno,@sname,@sage,@ssex,@sdep)
end
展开全部
SQL SERVER中实现:
create trigger tri_del_stu
on student
for delete
as
begin
insert into student_log
select * from deleted
end
ORACLE中实现:
create or replace trigger tri_del_stu
before delete on student
for each row
begin
insert into student_log(stuno,stuname) values(:old.stuno,:old.stuname);
end;
/
(注: 此处假设表只有stuno,stuname两列)!
create trigger tri_del_stu
on student
for delete
as
begin
insert into student_log
select * from deleted
end
ORACLE中实现:
create or replace trigger tri_del_stu
before delete on student
for each row
begin
insert into student_log(stuno,stuname) values(:old.stuno,:old.stuname);
end;
/
(注: 此处假设表只有stuno,stuname两列)!
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询