oracle中如何用delect删除两个关联的表的一条信息,要是用delete不行那应该用什么?

如题所述

如果关联的两个表一条信息同时删除,可用下列方法。
设关联的外键是ID,先设定外键类型为级联删除。
alter table B add constraint fk_ID foreign key (ID) references A(ID) on delete cascade;
然后delete from A where ID=nnnn; 就可以自动删除对应B表内容了。
温馨提示:答案为网友推荐,仅供参考
第1个回答  2012-07-31
如果关联的两个表一条信息同时删除,可用下列方法。
设关联的外键是ID,先设定外键类型为级联删除。
alter table B add constraint fk_ID foreign key (ID) references A(ID) on delete cascade;
然后delete from A where ID=nnnn; 就可以自动删除对应B表内容了。
第2个回答  2012-07-27
delete from table a,table b where a.? = b.?