0
我試圖創建兩個表如下,MySQL的REFFERENCE關鍵問題,phpMyAdmin的錯誤代碼150
--
-- Table structure for table `users`
--
CREATE TABLE IF NOT EXISTS `users` ( `Id` int(11) NOT NULL
AUTO_INCREMENT, `UserType` varchar(32) DEFAULT NULL, `FirstName`
varchar(64) DEFAULT NULL, `LastName` varchar(64) DEFAULT NULL,
`Email` varchar(64) DEFAULT NULL, `CompanyName` varchar(64) DEFAULT
NULL, `Telephone` varchar(64) DEFAULT NULL, `Country` varchar(64)
DEFAULT NULL, `Website` varchar(64) DEFAULT NULL, `JobTitle`
varchar(64) DEFAULT NULL, `Active` int(1) DEFAULT NULL, `Notes`
text, `DateOfRegistration` datetime DEFAULT NULL, PRIMARY KEY
(`Id`)) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
--
-- Table structure for table `login`
--
CREATE TABLE IF NOT EXISTS `login` ( `Id` int(11) NOT NULL,
`Username` varchar(64) NOT NULL, `Email` varchar(64) NOT NULL,
`Password` varchar(64) NOT NULL, `FailedAttemptCount` int(2) NOT
NULL, `LastLogin` datetime NOT NULL, `UserLevel` int(1) NOT NULL,
`IsVerified` int(1) NOT NULL DEFAULT '0', `VerificationKey`
varchar(256) NOT NULL, `VerifiKeyCreated` datetime NOT NULL,
PRIMARY KEY (`Id`), FOREIGN KEY (`Id`) REFERENCES users.Id, UNIQUE
KEY `username` (`Username`), UNIQUE KEY `Email` (`Email`))
ENGINE=InnoDB DEFAULT CHARSET=latin1;
我想添加一個外鍵即login.Id引用users.Id,但我得到錯誤(代碼150)在phpmyadmin。
在此先感謝您的幫助!
最好的問候, Rajib
我投票結束這個簡單的印刷錯誤。它應該是'FOREIGN KEY(ID)REFERENCES users(id)' – AdamMc331