Skip to content

Instantly share code, notes, and snippets.

@doi-t
Created July 16, 2014 06:07
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 doi-t/b893b7eea9b68a58b410 to your computer and use it in GitHub Desktop.
Save doi-t/b893b7eea9b68a58b410 to your computer and use it in GitHub Desktop.
単純なinsertの繰り返しと、バルクインサートのDDLを生成するスクリプト
#!/bin/bash
if [ $# -ne 2 ]; then
echo "$0 [the number of insert] [output file]"
exit 1
fi
nmemb_insert=$1
ddlfile=$2
cat <<- EOF > $ddlfile
use dbstudy
truncate table emp;
EOF
echo -n "insert into emp values" >> $ddlfile
for i in `seq 1 $nmemb_insert`
do
echo -n "(8000,'MySQL','DBA',null,sysdate(),5000,null,80)," >> $ddlfile
done
sed -i 's/,$/;/' $ddlfile
#!/bin/bash
if [ $# -ne 2 ]; then
echo "$0 [the number of insert] [output file]"
exit 1
fi
nmemb_insert=$1
ddlfile=$2
cat <<- EOF > $ddlfile
use dbstudy
truncate table emp;
EOF
for i in `seq 1 $nmemb_insert`
do
echo "insert into emp values(8000,'MySQL','DBA',null,sysdate(),5000,null,80);" >> $ddlfile
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment