Code:
#testcase
set -x
DB="ZYX"
DIR="/var/lib/mysql/${DB}"
FILE="${DIR}/x.csv"
mysql <<EOD
create database ${DB};
use ${DB};
CREATE TABLE Food2 (
PLU CHAR(6) ,
Item varchar(30) ,
Type varchar(30) ,
Size varchar(10) ,
InStock int(5) ,
OrderPoint tinyint(5),
OPFlag tinyint(1),
StockWanted int(3) ,
Price float ,
WeightFlag tinyint(1) ,
PRIMARY KEY (PLU)
);
EOD
cat <<EOD2 > ${FILE}
3615,"APPLES","Civni",,,,,,,
3630,"APPLES","Co-op 43",,,,,,,
4104,"APPLES","Cortland","Small",10,5,0,15,0.25,1
4106,"APPLES","Cortland","Large",12,5,0,15,0.30,1
4105,"APPLES","Cox Orange Pippin",,,,,,,
4107,"APPLES","Crab",,15,7,0,25,0.15,0
EOD2
mysql << EOD3
use ${DB}
load data infile '${FILE}' into table Food2 fields terminated by ',' enclosed by '"' lines terminated by '\n' ;
EOD3