Home > database >  sqlerror1215
sqlerror1215

Time:09-17

The create table Artist
(
Id INT auto_increment primary key,
The name char (20),
Birthday date,
Sex char (2),
Imdbnumber char (9),
The introduction varchar (100)
);
The create table Movie
(
Id INT auto_increment primary key,
The name char (20),
Releasedate date,
Duration int,
Language char (8),
The introduction varchar (100)
);
The create table Participation
(
Id INT auto_increment primary key,
Artistid int,
Movieid int,
Rolename char (20),
Foreign key (artistid) references Arist (id),
Foreign key references (movieid) Movie (id)
);
It has been an error code error 1215, which is why

CodePudding user response:

Foreign key (artistid) references Arist (id), the inside of the table name to write wrong, was too careless, this 20 points should return to me, it absolutely is the only answer;

Change the Arist to Artist;

CodePudding user response:

The meaning of the error code 1215 is:
MySQL error code 1215 (ER_CANNOT_ADD_FOREIGN) : always add a foreign key constraint
Upstairs positive solution, it is the name of the table to write the wrong cause the failure of foreign key constraints to establish,

After mysql installation comes with a command-line tool perror, various error codes can be used to query specific meaning,
  • Related