Load Data infile SQL for MySQL
Posted on 2016-08-24
I can not get the following SQL code to work to load data properly from a txt file created in Windows Notepad. I have included the create statements for the database schema and table.
create database shr2;
CREATE TABLE `shr2` (
`shrcode` char(3) COLLATE latin1_general_cs NOT NULL,
`shrfirm` varchar(20) COLLATE latin1_general_cs DEFAULT NULL,
`shrprice` decimal(6,2) DEFAULT NULL,
`shrqty` decimal(8,0) DEFAULT NULL,
`shrdiv` decimal(5,2) DEFAULT NULL,
`shrpe` decimal(2,0) DEFAULT NULL,
PRIMARY KEY (`shrcode`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs;
drop database shr2;
LOAD DATA LOCAL INFILE
'/MySQL/shhr.txt' INTO TABLE shr2
FIELDS TERMINATED BY ','
ENCLOSED BY '''
LINES TERMINATED BY '\r\n'; /*this is where I keep getting the error*/