日期:2014-05-18 浏览次数:20662 次
create table t1
(id int not null primary key,
de varchar(5)
)
insert into t1
select 1,'a' union all
select 2,'b' union all
select 3,'c'
create table t2
(id int not null
constraint fk_t1_id foreign key references t1(id)
on delete cascade
)
insert into t2(id) values(1)
insert into t2(id) values(3)
-- 删除t1.id=1,级联删除t2.id=1.
delete from t1 where id=1
select * from t1
/*
id de
----------- -----
2 b
3 c
*/
select * from t2
/*
id
-----------
3
*/