Skip to content

Instantly share code, notes, and snippets.

@joyeecheung
Created March 18, 2014 13:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joyeecheung/9619766 to your computer and use it in GitHub Desktop.
Save joyeecheung/9619766 to your computer and use it in GitHub Desktop.
Litter helper to generate loading command when building TPC-H.
#!/bin/bash
write_to_file()
{
file="loaddata.sql"
if [ ! -f "$file" ] ; then
touch "$file"
fi
echo 'USE tpch;\n' >> $file
DIR=`pwd`
for tbl in `ls *.tbl`; do
table=$(echo "${tbl%.*}" | tr '[:lower:]' '[:upper:]')
echo "LOAD DATA LOCAL INFILE '$DIR/$tbl' INTO TABLE $table" >> $file
echo "FIELDS TERMINATED BY '|' LINES TERMINATED BY '|\\\n';\n" >> $file
done
}
write_to_file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment