I'm trying to build the following in SQL fiddle and cannot for the life of me see why it will not work, it may just be late but can anyone offer pointers on this one please.
CREATE TABLE Trainers (
Trainer_ID INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
Firstname VARCHAR(30) NOT NULL,
Lastname VARCHAR(30) NOT NULL,
Email VARCHAR(50) NOT NULL,
DOB DATE
);
CREATE TABLE Captured
(
Caught_ID INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
Trainer_ID INT(6),
Caught TIMESTAMP,
FOREIGN KEY (Trainer_ID) REFERENCES Trainers(Trainer_ID)
);
Your FK is SIGNED
and thus is a different type than Trainer
's PK, an UNSIGNED
INT(6)
; change Captured.Trainer_ID
to INT(6) UNSIGNED
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.