The following is a code snippet for a create table script that my team is using for a project. The script works on our server, but fails with the error 150 on my local machine, it is driving me mad.
(the script is a lot longer and includes drop table for all tables at the beginning)
/* Create Type table */
CREATE TABLE Types
(typeID TINYINT not null,
typeName VARCHAR (7) not null,
PRIMARY KEY (typeID));
/* Create Event table */
CREATE TABLE Event
(title VARCHAR (25) not null,
typeID TINYINT not null,
description VARCHAR (100),
PRIMARY KEY (title),
FOREIGN KEY (typeID) REFERENCES Types);
I've attempted to fix this through searching but every result I've come across says to check data-type, etc. The code looks good to me so I can't for the life of me figure it out. Any set of eyes to peak would be appreciated.
Thanks!
您需要在定义外键时通知references
表的哪个字段
FOREIGN KEY (typeID) REFERENCES Types(typeID));
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.