0
這是我使用的查詢:錯誤代碼:1215無法添加新的外鍵約束
alter table publication1 add foreign key (Venuekey) references publicationvenue.venueKey
和下面是該查詢的兩個表:
出版表:
CREATE TABLE `publication1`
(
`keypub` varchar(200) CHARACTER SET latin1 COLLATE latin1_general_cs NOT NULL,
`title` varchar(700) DEFAULT NULL,
`booktitle` varchar(250) DEFAULT NULL,
`journal` varchar(250) DEFAULT NULL,
`volume` varchar(50) CHARACTER SET latin1 DEFAULT NULL,
`month` varchar(50) CHARACTER SET latin1 DEFAULT NULL,
`year` varchar(50) CHARACTER SET latin1 DEFAULT NULL,
`cdrom` varchar(250) CHARACTER SET latin1 DEFAULT NULL,
`ee` varchar(500) CHARACTER SET latin1 DEFAULT NULL,
`publisher` varchar(250) CHARACTER SET latin1 DEFAULT NULL,
`pages` varchar(50) CHARACTER SET latin1 DEFAULT NULL,
`number` varchar(50) CHARACTER SET latin1 DEFAULT NULL,
`url` varchar(500) CHARACTER SET latin1 DEFAULT NULL,
`cite` varchar(250) CHARACTER SET latin1 DEFAULT NULL,
`address` varchar(250) CHARACTER SET latin1 DEFAULT NULL,
`note` varchar(500) CHARACTER SET latin1 DEFAULT NULL,
`isbn` varchar(50) CHARACTER SET latin1 DEFAULT NULL,
`series` varchar(250) CHARACTER SET latin1 DEFAULT NULL,
`school` varchar(250) CHARACTER SET latin1 DEFAULT NULL,
`chapter` varchar(250) CHARACTER SET latin1 DEFAULT NULL,
`crossref` varchar(250) CHARACTER SET latin1 DEFAULT NULL,
`type` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
`venueClean` varchar(250) DEFAULT NULL,
`venuekey` varchar(200) DEFAULT NULL,
PRIMARY KEY (`keypub`),
KEY `venue_index` (`venueClean`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='InnoDB free: 49152 kB;
InnoDB free: 5424128 kB';
而第二個表我小號PublicationVenue
:
CREATE TABLE `publicationvenue` (
`venuekey` varchar(200) NOT NULL,
`VenueName` varchar(1000) DEFAULT NULL,
PRIMARY KEY (`venuekey`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
我已經設置了默認字符集相同的兩個表和列,並完成了所有諸如此類的事情,但仍然無法解決此查詢,請幫助?
非常感謝你。它工作 –
@RadheshyamKarnani你可以把這個答案作爲「接受」嗎?這將幫助我提高我的聲譽,並繼續回答其他用戶:) –
伊萬我已經標記爲接受..感謝您的答覆。 –