若有两个表~~~
A
-------------------------------------------------
id name 。。B
-----------------------------------------
id 。。定义一个触发器
当删除A表的行时 B表中id相同的行也删除
不知道看懂了没~~~
A
-------------------------------------------------
id name 。。B
-----------------------------------------
id 。。定义一个触发器
当删除A表的行时 B表中id相同的行也删除
不知道看懂了没~~~
AFTER DELETE
AS
DELETE B
FROM B,deleted AS A
WHERE B.id = A.id;
GO
create trigger tg_a
on a
after delete
begin
delete from b where id in (select id from deleted)
end