触发器 剔除级联建立 求指导
触发器 删除级联建立 求指导
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
------解决方案--------------------
直接使用外键级联删除不就行了?
------解决方案--------------------
呃~~可以的话 也不用这么费事了~~作业~
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
------解决方案--------------------
直接使用外键级联删除不就行了?
------解决方案--------------------
呃~~可以的话 也不用这么费事了~~作业~