我想删除中的主键。因此,我将子中的外键设置为delete级联。为什么这个不起作用?我需要先删除外键吗?如果是,那么delete on级联语句的过程是什么?
create database table_test;
use table_test;
create table father(
cod int,
primary key (cod)
);
create table child(
cod int,
cod_father int,
primary key(cod),
constraint fk_cod_father foreign key (cod_father) references father(cod)
on delete cascade
);
alter table father
drop primary key;发布于 2022-07-15 14:24:11
在删除父表的行时,
ON DELETE级联约束在MySQL中用于自动删除子表中的行。
您希望删除主键,在您的情况下,首先需要取消链接外键引用。所以先放下外键。
https://stackoverflow.com/questions/72995434
复制相似问题