我对mysql不是很熟悉,当我尝试更新数据库时,它给了我以下错误:
无法添加或更新子行:外键约束失败 (
lhollowa
.Concert
, CONSTRAINTConcert_ibfk_1
FOREIGN KEY (BandID
) REFERENCESBands
(BandID
))
我对自己做错了什么一无所知,有人能指出我正确的方向吗?
这是我拥有的一些东西(其余的会占用太多空间)。
DROP TABLE IF EXISTS `Bands`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `Bands` (
`BandID` int(11) NOT NULL AUTO_INCREMENT,
`BandName` varchar(30) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
PRIMARY KEY (`BandID`)
);
DROP TABLE IF EXISTS `Songs`;
CREATE TABLE `Songs` (
`SongID` int(11) NOT NULL AUTO_INCREMENT,
`SongTitle` varchar(50) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
PRIMARY KEY (`SongID`)
) ENGINE=InnoDB AUTO_INCREMENT=481 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE TABLE `Concert` (
`ConcertID` int (40) NOT NULL AUTO_INCREMENT,
`BandID` INT (40) NOT NULL DEFAULT '0',
`Concert_Time` varchar (20) COLLATE utf8_unicode_ci DEFAULT NULL,
`Venue_Name` varchar (40) COLLATE utf8_unicode_ci DEFAULT NULL,
`Number_Seats` int (10) NOT NULL DEFAULT '0',
`Number_Tickets` int (10) NOT NULL DEFAULT '0',
PRIMARY KEY (ConcertID),
FOREIGN KEY (BandID) REFERENCES Bands(BandID)
);
INSERT INTO `Concert` VALUES (82838283,1111111, 'noon', 'the razz', 139, 138);