今天,我將別人發給我的整個表的sql導出數據庫中,卻報錯了:
There was error(s) while executing the queries .
The query and the error message has been logged at:
C:\Users\傑\AppData\Roaming\SQLyog\sqlyog.err.
Please click on "Open Error File..." to open the error file.
這裏大概意思是:
在執行查詢時發現一個錯誤,查詢過程和錯誤信息被記錄在:C:\C:\Users\Administrator\AppData\Roaming\SQLyog\sqlyog.err.
於是我只好打開這個文件,發現裏面報的是:
Query:
CREATE TABLE `user` (
`Id` int(11) NOT NULL AUTO_INCREMENT,
`Account` varchar(30) DEFAULT NULL,
`Password` varchar(30) DEFAULT NULL,
`Status` int(11) DEFAULT NULL,
`EmployeeId` int(11) DEFAULT NULL,
`LatestLogin` datetime DEFAULT NULL,
`UserName` varchar(50) DEFAULT NULL,
`roleIdList` varchar(400) DEFAULT NULL,
`roleNameList` varchar(800) DEFAULT NULL,
`isolatedareaNo` varchar(255) DEFAULT NULL,
`isteamer` int(11) DEFAULT NULL,
`passArea` varchar(255) DEFAULT NULL,
`remark` varchar(255) DEFAULT NULL,
`validateDate` datetime DEFAULT NULL,
`headImgPath` varchar(255) DEFAULT NULL,
PRIMARY KEY (`Id`),
KEY `FK_EmployeeId` (`EmployeeId`) USING BTREE,
KEY `FK36EBCBFFF5E7D0` (`EmployeeId`) USING BTREE,
CONSTRAINT `user_ibfk_1` FOREIGN KEY (`EmployeeId`) REFERENCES `employee` (`Id`)
) ENGINE=InnoDB AUTO_INCREMENT=66 DEFAULT CHARSET=utf8
Error occured at:2015-10-13 23:11:28
Line no.:2048
Error Code: 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'USING BTREE,
KEY `FK36EBCBFFF5E7D0` (`EmployeeId`) USING BTREE,
CONSTRAINT `' at line 18
查了一下資料,才知道mysql版本的問題,mysql5.0和mysql5.1在處理到索引語句時有所區別。
解決方法:
KEY `FK36EBCBFFF5E7D0` (`EmployeeId`) USING BTREE
修改爲:
KEY `FK36EBCBFFF5E7D0` USING BTREE (`EmployeeId`)
這樣就可以完美解決了!