我正在使用 MySQL Workbench 并尝试更改列名。该列是许多外键的一部分。
我在想这就是导致错误的原因。我正在尝试重命名strCustomerCode
为strCustomerCodeNEW
代码:
ALTER TABLE `Check4It_MainDB`.`tbl_000_010_MAIN_REPORT_INFO`
CHANGE COLUMN `strCustomerCode` `strCustomerCodeNEW` VARCHAR(255)
CHARACTER SET 'utf8' NOT NULL ;
这是错误:
错误 1025:将“./Check4It_MainDB/#sql-b6a_4a5”重命名为“./Check4It_MainDB/tbl_000_010_MAIN_REPORT_INFO”时出错(错误号:150)
SQL 语句:
ALTER TABLE `Check4It_MainDB`.`tbl_000_010_MAIN_REPORT_INFO`
CHANGE COLUMN `strCustomerCode` `strCustomerCodeNEW` VARCHAR(255)
CHARACTER SET 'utf8' NOT NULL
错误:运行故障回复脚本时出错。详细信息如下
错误 1046:未选择数据库
SQL 语句:
CREATE TABLE `tbl_000_010_MAIN_REPORT_INFO` (
`strCustomerCode` varchar(255) CHARACTER SET utf8 NOT NULL'
`strPasscodeAdmin` varchar(255) CHARACTER SET utf8 NOT NULL,
`strPasscodeClient` varchar(255) CHARACTER SET utf8 NOT NULL,
`idMainReport_ID` int(11) NOT NULL AUTO_INCREMENT,
`lngProcedure_ID` int(11) DEFAULT NULL,
`strHardDriveID` varchar(255) CHARACTER SET utf8 DEFAULT NULL,
`lngInspector_01_ID` int(11) DEFAULT NULL,
`lngInspector_02_ID` int(11) DEFAULT NULL,
`lngShift_ID` int(11) DEFAULT NULL,
`lngUnit_ID` int(11) DEFAULT NULL,
`dtmReportCreated` datetime DEFAULT NULL,
`dtmReportSubmitted` datetime DEFAULT NULL,
`bolCompleted` bit(1) DEFAULT b'0',
`memReportComments` longtext CHARACTER SET utf8,
`strTextMessage` varchar(160) CHARACTER SET utf8 DEFAULT NULL,
`bolTextMessageOn` bit(1) DEFAULT b'0',
`bolTextSent` bit(1) DEFAULT b'0',
`bolReportEmailSent` bit(1) DEFAULT b'0',
`bolCompletionEmailSent` bit(1) DEFAULT b'0',
`bolReportPostedToCloud` bit(1) DEFAULT b'0',
`strComputerName` varchar(255) CHARACTER SET utf8 DEFAULT NULL,
`strUserLogin` varchar(255) CHARACTER SET utf8 DEFAULT NULL,
`strUserVersionNUmber` varchar(255) CHARACTER SET utf8 DEFAULT NULL,
`bolImportedReport` bit(1) DEFAULT NULL,
`bolTestReport` bit(1) DEFAULT b'0',
`strOSVersion` varchar(255) CHARACTER SET utf8 DEFAULT NULL,
`strWindowsVersion` varchar(255) CHARACTER SET utf8 DEFAULT NULL,
PRIMARY KEY (`idMainReport_ID`, `strCustomerCode`, `strPasscodeAdmin`, `strPasscodeClient`),
KEY `idMainTest_ID1` (`lngProcedure_ID`),
KEY `idProcedure_ID` (`idMainReport_ID`),
KEY `lngMemebrInfoID` (`lngInspector_01_ID`),
KEY `lngShift_ID` (`lngShift_ID`),
KEY `lngUnit_ID` (`lngUnit_ID`),
KEY `strHardDriveID` (`strHardDriveID`),
KEY `strPasscodeClient` (`strPasscodeClient`),
KEY `tbl_000_010_MAIN_REPORT_INFOstrPasscodeAdmin` (`strPasscodeAdmin`),
KEY `tblREF_InspectorInfotbl_000_010_MAIN_REPORT_INFO` (`lngInspector_01_ID`,`strCustomerCode`),
KEY `strPasscodeAdmin` (`strPasscodeAdmin`,`strCustomerCode`,`lngProcedure_ID`),
KEY `idMainReport_ID` (`idMainReport_ID`,`strPasscodeAdmin`,`strCustomerCode`,`strPasscodeClient`),
KEY `strCustomerCode` (`strCustomerCode`,`lngInspector_02_ID`),
KEY `lngShift_ID_2` (`lngShift_ID`,`strCustomerCode`),
KEY `strCustomerCode_2` (`strCustomerCode`,`lngUnit_ID`),
CONSTRAINT `FK_WithShiftID` FOREIGN KEY (`lngShift_ID`) REFERENCES `tblREF_ShiftID` (`idShift_ID`)
ON DELETE CASCADE ON UPDATE CASCADE)
ENGINE=InnoDB AUTO_INCREMENT=63 DEFAULT CHARSET=latin1