我厌倦了检查两个表的关系,并将所有内容进行匹配,看看他们是否使用了不同的引擎。但由于某种原因,我无法创建“好友”表:
DROP TABLE IF EXISTS `buddies`;
CREATE TABLE `buddies` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`characterid` int(11) NOT NULL,
`buddyid` int(11) NOT NULL,
`pending` tinyint(4) NOT NULL DEFAULT '0',
`groupname` varchar(16) NOT NULL DEFAULT 'ETC',
PRIMARY KEY (`id`),
KEY `buddies_ibfk_1` (`characterid`),
CONSTRAINT `buddies_ibfk_1` FOREIGN KEY (`characterid`) REFERENCES `characters` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=7998 DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC;
DROP TABLE IF EXISTS `characters`;
CREATE TABLE `characters` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`accountid` int(11) NOT NULL DEFAULT '0',
`world` tinyint(1) NOT NULL DEFAULT '0',
`name` varchar(13) NOT NULL DEFAULT '',
`level` int(3) NOT NULL DEFAULT '0',
`exp` int(11) NOT NULL DEFAULT '0',
`str` int(5) NOT NULL DEFAULT '0',
`dex` int(5) NOT NULL DEFAULT '0',
`luk` int(5) NOT NULL DEFAULT '0',
`int` int(5) NOT NULL DEFAULT '0',
`hp` int(5) NOT NULL DEFAULT '0',
`mp` int(5) NOT NULL DEFAULT '0',
`maxhp` int(5) NOT NULL DEFAULT '0',
`maxmp` int(5) NOT NULL DEFAULT '0',
`meso` int(11) NOT NULL DEFAULT '0',
`hpApUsed` int(5) NOT NULL DEFAULT '0',
`job` int(5) NOT NULL DEFAULT '0',
`skincolor` tinyint(1) NOT NULL DEFAULT '0',
`gender` tinyint(1) NOT NULL DEFAULT '0',
`fame` int(5) NOT NULL DEFAULT '0',
`hair` int(11) NOT NULL DEFAULT '0',
`face` int(11) unsigned NOT NULL DEFAULT '0',
`faceMarking` int(11) NOT NULL DEFAULT '0',
`ap` int(11) NOT NULL DEFAULT '0',
`map` int(11) NOT NULL DEFAULT '0',
`spawnpoint` int(3) NOT NULL DEFAULT '0',
`gm` int(3) NOT NULL DEFAULT '0',
`party` int(11) NOT NULL DEFAULT '0',
`buddyCapacity` int(11) NOT NULL DEFAULT '25',
`createdate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`guildid` int(10) unsigned NOT NULL DEFAULT '0',
`guildrank` tinyint(1) unsigned NOT NULL DEFAULT '5',
`allianceRank` tinyint(1) unsigned NOT NULL DEFAULT '5',
`guildContribution` int(11) NOT NULL DEFAULT '0',
`pets` varchar(13) NOT NULL DEFAULT '-1,-1,-1',
`sp` varchar(255) NOT NULL DEFAULT '0,0,0,0,0,0,0,0,0,0',
`subcategory` int(11) NOT NULL DEFAULT '0',
`rank` int(11) NOT NULL DEFAULT '1',
`rankMove` int(11) NOT NULL DEFAULT '0',
`jobRank` int(11) NOT NULL DEFAULT '1',
`jobRankMove` int(11) NOT NULL DEFAULT '0',
`marriageId` int(11) NOT NULL DEFAULT '0',
`familyid` int(11) NOT NULL DEFAULT '0',
`seniorid` int(11) NOT NULL DEFAULT '0',
`junior1` int(11) NOT NULL DEFAULT '0',
`junior2` int(11) NOT NULL DEFAULT '0',
`currentrep` int(11) NOT NULL DEFAULT '0',
`totalrep` int(11) NOT NULL DEFAULT '0',
`gachexp` int(11) NOT NULL DEFAULT '0',
`fatigue` tinyint(4) NOT NULL DEFAULT '0',
`charm` mediumint(7) NOT NULL DEFAULT '0',
`craft` mediumint(7) NOT NULL DEFAULT '0',
`charisma` mediumint(7) NOT NULL DEFAULT '0',
`will` mediumint(7) NOT NULL DEFAULT '0',
`sense` mediumint(7) NOT NULL DEFAULT '0',
`insight` mediumint(7) NOT NULL DEFAULT '0',
`totalWins` int(11) NOT NULL DEFAULT '0',
`totalLosses` int(11) NOT NULL DEFAULT '0',
`pvpExp` int(11) NOT NULL DEFAULT '0',
`pvpPoints` int(11) NOT NULL DEFAULT '0',
`rebirths` int(11) NOT NULL DEFAULT '0',
`prefix` varchar(45) DEFAULT NULL,
`reborns` int(11) NOT NULL DEFAULT '0',
`apstorage` int(11) NOT NULL DEFAULT '0',
`elf` int(11) NOT NULL DEFAULT '0',
`honourExp` int(11) NOT NULL DEFAULT '0',
`honourLevel` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `accountid` (`accountid`),
KEY `guildid` (`guildid`),
KEY `familyid` (`familyid`),
KEY `marriageId` (`marriageId`),
KEY `seniorid` (`seniorid`)
) ENGINE=InnoDB AUTO_INCREMENT=124 DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC;
每次我执行上面,我得到:错误代码:1005。无法创建表(错误号:150)0.000秒
答案 0 :(得分:1)
将buddies
放在最后,以便它可以引用characters
。
答案 1 :(得分:1)
您是否尝试更改创建表的顺序?伙计们正在尝试使用可能不存在的字符创建一个外键约束的表。