0
我想更改/更新SQL中某个表的PK。我使用Wampserver。 但是这个PK被用作外部的3个其他表,我不能改变它。 任何想法如何?我可以禁用FK,然后再次启用它们,它们将拥有新的PK? 在与PK的表格中,有5-6个PK,但我只想改变其中的一个。在SQL中更改PK,由于FK而不起作用
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
);
重复? http://stackoverflow.com/questions/1191023/changing-mysql-primary-key-when-foreign-key-contraints-exist –
你是什么意思?如果PK是重复的? ofc no。 我的意思是表格5-6不同的PK,我只想改变其中的一个。但是这个PK作为FK存在于其他表格中,并且其中一些不止一次(因为它是FK) – nickD3
我指的是到一个类似的问题。你看看那里提供的解决方案吗?我猜这个问题将与InnoDB ENGINE有关。因为你已经为你的FK和PK之间的关系设置了一个限制,所以你不能删除它。 –