I'm getting a couple of errors with Load Data Infile; the first is that it's telling me there's a foreign key error where there isn't. I'm using the following query:
load data local infile '(my file name)' ignore into table subelements fields terminated by ',' lines terminated by '\r\n';
The file I'm loading is a one-line CSV (for test purposes):
ATO,Base,\N,\N,\N,\N,\N,\N
The error:
Error Code: 1452. Cannot add or update a child row: a foreign key constraint fails (`watts`.`subelements`, CONSTRAINT `sebSculptID` FOREIGN KEY (`SculptID`) REFERENCES `sculptures` (`SculptID`) ON DELETE CASCADE ON UPDATE CASCADE)
The table and the one it references:
CREATE TABLE `subelements` (
`LocNum` int(6) unsigned NOT NULL AUTO_INCREMENT,
`SculptID` char(3) NOT NULL,
`ElementName` char(20) DEFAULT NULL,
`ElementNumber` char(2) DEFAULT NULL,
`SubElementName` char(20) DEFAULT NULL,
`SubElementNumber` char(2) DEFAULT NULL,
`ThirdElementName` char(15) DEFAULT NULL,
`ThirdElementNumber` char(2) DEFAULT NULL,
`Letter` char(2) DEFAULT NULL,
PRIMARY KEY (`LocNum`),
KEY `seSculptID` (`SculptID`),
KEY `sebSculptID` (`SculptID`),
CONSTRAINT `sebSculptID` FOREIGN KEY (`SculptID`) REFERENCES `sculptures` (`SculptID`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=2345 DEFAULT CHARSET=utf8
CREATE TABLE `sculptures` (
`SculptID` char(3) NOT NULL,
`SculptName` varchar(20) NOT NULL,
`MaxX` int(4) unsigned NOT NULL DEFAULT '0',
`MaxY` int(4) unsigned NOT NULL DEFAULT '0',
`MaxZ` int(4) unsigned NOT NULL DEFAULT '0',
`Orientations` int(1) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`SculptID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
ATO is the first SculptID in the table Sculptures. It's capitalized and doesn't contain whitespace or anything.