primary key (par_id,child_id),
foreign key (par_id) references parent (par_id) on delete cascade
) type = innodb;
# creat table end
# insert strat
insert into parent (par_id) values (1),(2),(3);
insert into child (par_id,child_id) values (1,1),(1,2);
insert into child (par_id,child_id) values (2,1),(2,2),(2,3);
insert into child (par_id,child_id) values (3,1);
# insert end
文章来源于领测软件测试网 https://www.ltesting.net/