create trigger tduStudent
on aa for insert
as
begin
declare @id int
select @id=id from inserted
insert into bb (id) values(@id)
end
drop table aa
create table aa (
id int identity(1,1) not null,
name VARCHAR(10),
sex int,
constraint PK_AA primary key (id)
);
insert into aa values('123',1);
drop table bb
create table bb (
id int not null,
name VARCHAR(20),
ffff VARCHAR(20),
constraint PK_BB primary key (id)
);
update bb set name='123', ffff='123' where id in (SELECT MAX(id) FROM bb);
select * from bb
alter table bb
add constraint FK_BB_REFERENCE_AA foreign key (id)
references aa (id) ON DELETE CASCADE;
表上的级联插入
最新推荐文章于 2023-01-08 18:46:02 发布