MySQL说:文档#1005 - 无法创建表`music` .track`(错误:150"外键约束形成错误")

时间:2018-02-19 18:03:01

标签: mysql

CREATE DATABASE music DEFAULT CHARACTER SET utf8;
CREATE TABLE Artist
(artist_id INTEGER NOT NULL AUTO_INCREMENT,
 name varchar(255),
 PRIMARY KEY(artist_id)
)
ENGINE = INNODB;
CREATE TABLE Album
(
album_id INTEGER NOT NULL AUTO_INCREMENT,
title varchar(255),
artist_id INTEGER,
PRIMARY KEY(album_id),
INDEX USING BTREE(title),
CONSTRAINT FOREIGN KEY (artist_id)
REFERENCES Artist(Artist_id)
ON DELETE CASCADE ON UPDATE CASCADE   
)
ENGINE = InnoDB;

CREATE TABLE Genre
(
genre_id INTEGER NOT NULL AUTO_INCREMENT,
name VARCHAR(255),
PRIMARY KEY(genre_id),
INDEX USING BTREE (name)
)
ENGINE = INNODB;

CREATE TABLE Track
(
track_id INTEGER NOT NULL AUTO_INCREMENT,
title VARCHAR(255),
len INTEGER,
rating INTEGER,
count INTEGER,
album_id INTEGER,
genre_id INTEGER,
PRIMARY KEY (track_id),
INDEX USING BTREE(title),

CONSTRAINT FOREIGN KEY (album_id) REFERENCES Album(albumn_id)
    ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT FOREIGN KEY(genre_id) REFERENCES Genre(genre_id)
)
ENGINE = INNODB;

我已多次检查过。怎么了?

1 个答案:

答案 0 :(得分:-1)

你拼错了外键

parameters.put("subReport", "/edu/ijse/gdse41/ams/reports/Answers.jasper");