我需要一个级联删除的例子。我的问题是,我在哪里添加它?在我创建 PK 的表中,或者在该 PK 作为 FK 坐在那里的其他表中?
我可以使用“alter table”将“on delete cascade”添加到现有表吗?请举个例子?
@edit MYSQL,使用 phpMyAdmin
@编辑 2
它看起来不错吗?
alter table wplaty
drop foreign key pesel,
add constraint pesel foreign key (pesel)
references baza_osob(pesel) on delete cascade on update restrict;
我的父表 = baza_osob 我的子表 = wplaty
PK 是 pesel,FK 也是 pesel。
@edit3 出现错误:
#1025 - 将 '.\projekt\wplaty' 重命名为 '.\projekt#sql2-1300-6c' 时出错(错误号:152)