连表删除 sql语句疑问
a表
id
name
b表
信息id
a表ID
连表删除:我删除a表的数据同时删除b表里面的id=a表的id 一起删除掉
额,大虾 看不懂
给你一个列子:
create table roomname(room_name varchar(50) primary key )
create table classroom
(
room_name varchar(50) foreign key references roomname(room_name) on delete cascade --级联删除
)
insert into roomname
values('4101')
insert into classroom
values('4101')
go
--没有报错
delete roomname
where room_name = '4101'
--自动删除
select * from classroom