收到此错误但无法查看树木的森林。
我的产品表:
CREATE TABLE IF NOT EXISTS `tblProducts` (
`productID` int(11) NOT NULL AUTO_INCREMENT,
`partNo` int(11) NOT NULL,
`productName` varchar(50) NOT NULL,
`description` mediumtext,
`unitPrice` decimal(10,2) NOT NULL DEFAULT '0.00',
`supplierPrice` decimal(10,2) DEFAULT '0.00',
`marginDiscount` double(8,0) NOT NULL DEFAULT '0',
`supplierID_FK` int(11) NOT NULL,
`categoryID_FK` int(11) NOT NULL,
`quantityPerUnit` varchar(20) NOT NULL DEFAULT '1',
`unitsInStock` smallint(2) DEFAULT '0',
`unitsOnOrder` smallint(2) DEFAULT '0',
`reorderLevel` smallint(2) DEFAULT '0',
`discontinued` bit(1) NOT NULL DEFAULT b'0',
PRIMARY KEY (`productID`),
KEY `ix_partNo` (`partNo`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
这是我无法创建的表格:
CREATE TABLE IF NOT EXISTS `tblProductAudit` (
`productAuditID` int(11) unsigned NOT NULL AUTO_INCREMENT,
`partNo` int(11) unsigned NOT NULL,
`changeType` enum('NEW','EDIT','DELETE') NOT NULL,
`changeTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`productAuditID`),
KEY `ix_part_id` (`partNo`),
KEY `ix_changeType` (`changeType`),
KEY `ix_changeTime` (`changeTime`),
CONSTRAINT `FK_audit_partNo_id` FOREIGN KEY (`partNo`) REFERENCES `tblProducts` (`productID`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
答案 0 :(得分:0)
tblProducts.ProductID字段是带符号的整数字段,而引用的PartNo字段是无符号的。这是一种类型不匹配。我还鼓励你在两个表中使用相同的字符集以避免混淆。