首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

触发器 剔除级联建立 求指导

2012-12-14 
触发器 删除级联建立 求指导create table zhigong(仓库号 char(4),职工号 char(10),工资numeric(5,1),cons

触发器 删除级联建立 求指导
  create table zhigong
(
仓库号 char(4),
职工号 char(10),
工资   numeric(5,1),
constraint zhigong1 primary key(职工号),
constraint zhigong2 foreign key (仓库号) references cangku (仓库号)
)

create table cangku
(仓库号 char(4),
 城市   nvarchar(3),
 面积   numeric(4),

constraint cangku1 primary key(仓库号),

)


create trigger delete_cangku
on cangku
for delete
as
begin
delete  from zhigong
where 仓库号 in (select 仓库号 from deleted)
end 
go

cangku表上删除一个记录时 zhigong表删除相关记录
应该怎么写?

[解决办法]
前触发 后触发 分清 before与after
[解决办法]
直接使用外键级联删除不就行了?
[解决办法]
呃~~可以的话 也不用这么费事了~~作业~

热点排行