Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
mysql在ALTER TABLE约束上失败:无法创建表(错误号:150)_Mysql_Sql - Fatal编程技术网

mysql在ALTER TABLE约束上失败:无法创建表(错误号:150)

mysql在ALTER TABLE约束上失败:无法创建表(错误号:150),mysql,sql,Mysql,Sql,我有以下SQL: CREATE TABLE face_group (id BIGINT AUTO_INCREMENT, name VARCHAR(100), description VARCHAR(200), pivotxpos FLOAT(18, 2) NOT NULL, pivotypos FLOAT(18, 2) NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, PRIMARY

我有以下SQL:

CREATE TABLE face_group (id BIGINT AUTO_INCREMENT, name VARCHAR(100), description     VARCHAR(200), pivotxpos FLOAT(18, 2) NOT NULL, pivotypos FLOAT(18, 2) NOT NULL, created_at        DATETIME NOT NULL, updated_at DATETIME NOT NULL, PRIMARY KEY(id)) ENGINE = INNODB;
CREATE TABLE face_image (id bigint NOT NULL, imageurl VARCHAR(200) NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL) ENGINE = INNODB;
CREATE TABLE face_tag (id bigint NOT NULL, name VARCHAR(100), tagtype VARCHAR(100), created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL) ENGINE = INNODB;
CREATE TABLE grouped_feature (id BIGINT AUTO_INCREMENT, name VARCHAR(100) NOT NULL, feature_id bigint NOT NULL, face_group_id bigint NOT NULL, pivotxposoverride FLOAT(18, 2) NOT   NULL, pivotyposoverride FLOAT(18, 2) NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX face_group_id_idx (face_group_id), INDEX feature_id_idx            (feature_id), PRIMARY KEY(id)) ENGINE = INNODB;
CREATE TABLE tagged_face (id bigint NOT NULL, face_image_id bigint NOT NULL, face_tag_id bigint NOT NULL, tag_value VARCHAR(100), created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX face_image_id_idx (face_image_id), INDEX face_tag_id_idx (face_tag_id)) ENGINE = INNODB;
CREATE TABLE tweaked_curve (id BIGINT AUTO_INCREMENT, tweaked_feature_id bigint NOT NULL, curve_id bigint NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL,     INDEX tweaked_feature_id_idx (tweaked_feature_id), INDEX curve_id_idx (curve_id), PRIMARY KEY(id)) ENGINE = INNODB;
CREATE TABLE tweaked_feature (id BIGINT AUTO_INCREMENT, face_group_id bigint NOT NULL, feature_id bigint NOT NULL, face_image_id bigint NOT NULL, pivotxpos FLOAT(18, 2) NOT NULL,  pivotypos FLOAT(18, 2) NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX face_group_id_idx (face_group_id), INDEX feature_id_idx (feature_id), INDEX      face_image_id_idx (face_image_id), PRIMARY KEY(id)) ENGINE = INNODB;
CREATE TABLE tweaked_point (id BIGINT AUTO_INCREMENT, tweaked_curve_id bigint NOT NULL, point_id bigint NOT NULL, xposoverride FLOAT(18, 2) NOT NULL, yposoverride FLOAT(18, 2) NOT NULL, user_tweaked TINYINT(1) DEFAULT '0' NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX tweaked_curve_id_idx (tweaked_curve_id), INDEX point_id_idx   (point_id), PRIMARY KEY(id)) ENGINE = INNODB;
ALTER TABLE grouped_feature ADD CONSTRAINT grouped_feature_feature_id_feature_id FOREIGN KEY (feature_id) REFERENCES feature(id) ON DELETE CASCADE;
ALTER TABLE grouped_feature ADD CONSTRAINT grouped_feature_face_group_id_face_group_id FOREIGN KEY (face_group_id) REFERENCES face_group(id) ON DELETE CASCADE;
ALTER TABLE tagged_face ADD CONSTRAINT tagged_face_face_tag_id_face_tag_id FOREIGN KEY (face_tag_id) REFERENCES face_tag(id) ON DELETE CASCADE;
ALTER TABLE tagged_face ADD CONSTRAINT tagged_face_face_image_id_face_image_id FOREIGN KEY (face_image_id) REFERENCES face_image(id) ON DELETE CASCADE;
ALTER TABLE tweaked_curve ADD CONSTRAINT tweaked_curve_tweaked_feature_id_tweaked_feature_id FOREIGN KEY (tweaked_feature_id) REFERENCES tweaked_feature(id) ON DELETE CASCADE;
ALTER TABLE tweaked_curve ADD CONSTRAINT tweaked_curve_curve_id_curve_id FOREIGN KEY (curve_id) REFERENCES curve(id) ON DELETE CASCADE;
ALTER TABLE tweaked_feature ADD CONSTRAINT tweaked_feature_feature_id_feature_id FOREIGN KEY (feature_id) REFERENCES feature(id) ON DELETE CASCADE;
ALTER TABLE tweaked_feature ADD CONSTRAINT tweaked_feature_face_image_id_face_image_id FOREIGN KEY (face_image_id) REFERENCES face_image(id) ON DELETE CASCADE;
ALTER TABLE tweaked_feature ADD CONSTRAINT tweaked_feature_face_group_id_face_group_id FOREIGN KEY (face_group_id) REFERENCES face_group(id) ON DELETE CASCADE;
ALTER TABLE tweaked_point ADD CONSTRAINT tweaked_point_tweaked_curve_id_tweaked_curve_id FOREIGN KEY (tweaked_curve_id) REFERENCES tweaked_curve(id) ON DELETE CASCADE;
ALTER TABLE tweaked_point ADD CONSTRAINT tweaked_point_point_id_point_id FOREIGN KEY (point_id) REFERENCES point(id) ON DELETE CASCADE;
ALTER TABLE tagged_face命令失败,出现一个奇怪的“无法创建表”错误150

我看过其他关于这个问题的帖子,但是我不知道我做错了什么,外键引用了相同类型的列,并且是唯一的。有人有什么想法吗


谢谢

我想这一切都失败了:

REFERENCES feature(id)
也许你必须参考:

REFERENCES grouped_feature(id)


在我的本地mysql数据库上进行了测试。

我认为这一切都失败了:

REFERENCES feature(id)
也许你必须参考:

REFERENCES grouped_feature(id)

在我的本地mysql数据库上测试。

您的face\u图像表没有索引。需要索引来监控外键约束

在face_image表上添加索引,您应该设置…

您的face_image表没有索引。需要索引来监控外键约束

在face_图像表上添加索引,您应该设置为