a表
id
name
b表
信息id
a表ID
连表删除:我删除a表的数据同时删除b表里面的id=a表的id 一起删除掉
------解决方案--------------------
如1楼说的触发器实现
create or replace trigger ab_delete
after delete on a
for each row
begin
delete from b where id = :old.id;
end;
------解决方案--------------------
12楼的看了没?
------解决方案--------------------
给你一个列子:
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