DROP TABLE IF EXISTS `tg_stone`;
CREATE TABLE `tg_stone` (
`id` int(11) NOT NULL,
`stage` char(10) default “”T””,
`user1` varchar(50) default NULL,
`user2` varchar(50) default NULL,
`choice1` int(11) default “”0″”,
`choice2` int(11) default “”0″”,
`allgold1` int(11) default “”-1″”,
`allgold2` int(11) default “”-1″”,
`status` char(10) default “”0″”,
`time` datetime default NULL,
`count` int(11) default “”0″”,
PRIMARY KEY (`id`),
KEY `choice1` (`choice1`),
KEY `choice2` (`choice2`),
CONSTRAINT `tg_stone_ibfk_1` FOREIGN KEY (`choice1`) REFERENCES `tg_stonetype` (`id`),
CONSTRAINT `tg_stone_ibfk_2` FOREIGN KEY (`choice2`) REFERENCES `tg_stonetype` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=gbk;
mysql5.6的版本高手帮本人看看这里怎么报1215 – Cannot add foreign key constraint错误
CREATE TABLE `tg_stone` (
`id` int(11) NOT NULL,
`stage` char(10) default “”T””,
`user1` varchar(50) default NULL,
`user2` varchar(50) default NULL,
`choice1` int(11) default “”0″”,
`choice2` int(11) default “”0″”,
`allgold1` int(11) default “”-1″”,
`allgold2` int(11) default “”-1″”,
`status` char(10) default “”0″”,
`time` datetime default NULL,
`count` int(11) default “”0″”,
PRIMARY KEY (`id`),
KEY `choice1` (`choice1`),
KEY `choice2` (`choice2`),
CONSTRAINT `tg_stone_ibfk_1` FOREIGN KEY (`choice1`) REFERENCES `tg_stonetype` (`id`),
CONSTRAINT `tg_stone_ibfk_2` FOREIGN KEY (`choice2`) REFERENCES `tg_stonetype` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=gbk;
mysql5.6的版本高手帮本人看看这里怎么报1215 – Cannot add foreign key constraint错误
解决方案:20分
tg_stonetype是这是建索引问题。