[HY000][1215]无法添加外键约束



应用程序用户

-- auto-generated definition
create table application_user
(
id        bigint auto_increment
primary key,
email     varchar(255) not null,
is_active bit          null,
name      varchar(255) not null,
password  varchar(255) not null,
surname   varchar(255) not null,
username  varchar(255) not null
)
engine = MyISAM;

我有一个由hibernate生成的表。我想手动创建一个表并添加一个外键。

到目前为止,我试过这个

application_user_log

CREATE TABLE application_user_log (
log_id BIGINT NOT NULL AUTO_INCREMENT,
fk_user_id BIGINT NOT NULL,
old_user_name BIGINT NOT NULL,
new_user_name BIGINT NOT NULL,
PRIMARY KEY (log_id),
FOREIGN KEY  (fk_user_id) REFERENCES application_user(id)
) ;

我收到了这个错误消息。:[HY000][1215] Cannot add foreign key constraint

为什么我会出现这个错误?

我不知道为什么我的答案会被转换成注释,但我知道MyISAM不支持外键。您可以在此处阅读详细信息。

最新更新