gpt4 book ai didi

mysql - 无法在mysql中添加外键约束

转载 作者:行者123 更新时间:2023-11-29 19:33:49 27 4
gpt4 key购买 nike

create table buys (    
user_id INT(11) not null,
software_id INT(11) not null,
associated_id INT(11) not null,
primary key (associated_id),
foreign key (software_id) references software,
foreign key (user_id) references users,
foreign key (associated_id) references associated);

我有一个三元关系关联表,具有完全参与和键约束,但无法添加外键约束

最佳答案

检查以下查询:

CREATE TABLE products(
prd_id int not null auto_increment primary key,
cat_id int not null,
FOREIGN KEY fk_cat(cat_id)
REFERENCES categories(cat_id)
)ENGINE=InnoDB;

就您而言:

foreign key (software_id) references software -> here column name is missing in software table

关于mysql - 无法在mysql中添加外键约束,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41634608/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com