In order to load my assignment's data, I followed these directions
Run "mysql < createdb.sql" to create database schema. Run "./loaddata.sh" to load data into the database.
I have successfully ran the createdb.sql using this command line
mysql> source /user/Desktop/sqllab/createdb.sql;
So what I have now is database but with empty tables.
To load the data from "loaddata.sh", I tried the command line
mysql> source /user/Desktop/sqllab/loaddata.sh;
but I got this error
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'for f in student faculty class enrolled emp dept works flights aircraft employee' at line 1
this is what's inside the loaddata.sh file
#! /bin/sh
# Load data in plain text files to tables
for f in student faculty class enrolled emp dept works flights aircraft employees certified suppliers parts catalog
do
echo "Inserting $f"
mysql --local-infile lab -e "load data local infile '$f.txt' into table $f columns terminated by ',' optionally enclosed by '\"' lines terminated by '\r\n'"
done
when I run
/user/Desktop/sqllab/loaddata.sh
I get:
Inserting student /user/Desktop/sqllab/loaddata.sh: line 8: mysql: command not found Inserting faculty /user/Desktop/sqllab/loaddata.sh: line 8: mysql: command not found Inserting class /user/Desktop/sqllab/loaddata.sh: line 8: mysql: command not found Inserting enrolled /user/Desktop/sqllab/loaddata.sh: line 8: mysql: command not found Inserting emp /user/Desktop/sqllab/loaddata.sh: line 8: mysql: command not found Inserting dept /user/Desktop/sqllab/loaddata.sh: line 8: mysql: command not found Inserting works /user/Desktop/sqllab/loaddata.sh: line 8: mysql: command not found Inserting flights /user/Desktop/sqllab/loaddata.sh: line 8: mysql: command not found Inserting aircraft /user/Desktop/sqllab/loaddata.sh: line 8: mysql: command not found Inserting employees /user/Desktop/sqllab/loaddata.sh: line 8: mysql: command not found Inserting certified /user/Desktop/sqllab/loaddata.sh: line 8: mysql: command not found Inserting suppliers /user/Desktop/sqllab/loaddata.sh: line 8: mysql: command not found Inserting parts /user/Desktop/sqllab/loaddata.sh: line 8: mysql: command not found Inserting catalog /user/Desktop/sqllab/loaddata.sh: line 8: mysql: command not found