我想更改/更新 SQL 中表的 PK。我用的是Wampserver。 但是这个 PK 被用作其他 3 个表的外来项,我无法更改它。 知道怎么做吗?我可以禁用 FK,然后再次启用它们,它们将拥有新的 PK 吗? 在有PK的表中,有5-6个PK,但我只想更改其中一个。
CREATE TABLE party(
name varchar(40) COLLATE utf8_general_ci NOT NULL primary key,
id integer not null,
foreign key (id) references arxhgos(id)
);
CREATE TABLE boul(
id integer not null,
foreign key (id) references person(id),
part_n varchar(40) COLLATE utf8_general_ci NOT NULL,
foreign key (part_n) references party(name),
date_beg date not null,
date_end date
);
最佳答案
您必须设置所谓的级联更新。
关于mysql - 在SQL中更改PK,由于FK而不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21617434/