应用程序用户
-- 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生成的表。我想创建一个表并手动添加一个外键。
到目前为止我试过这个
应用程序\用户\日志
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
为什么我会犯这个错误?
1条答案
按热度按时间tcbh2hod1#
我不知道为什么我的答案会被转换成评论,但我知道myisam不支持外键。你可以在这里阅读细节。