如何用触发器在MySQL数据库中删除A表一条数
1个回答
展开全部
使用delete 触发器格式:
CREATE trigger tri_update
on tablename
for delete
as
begin
--sql code
end
例:
CREATE trigger tri_update
on tablename1 --触发的表名
for delete
as
begin
declare @del_id varchar(40)
select @del_id = id from deleted --tablename1 中删除的数据保存在 deleted 中
delete tablename2 where id = @del_id --同步删除tablename2中数据
end
CREATE trigger tri_update
on tablename
for delete
as
begin
--sql code
end
例:
CREATE trigger tri_update
on tablename1 --触发的表名
for delete
as
begin
declare @del_id varchar(40)
select @del_id = id from deleted --tablename1 中删除的数据保存在 deleted 中
delete tablename2 where id = @del_id --同步删除tablename2中数据
end
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询