日期:2014-05-16  浏览次数:20653 次

MySQL笔记 - 根据指定SELECT语句生成INSERT语句
echo "select * from table_name" | mysql -uroot -Ddb_name | tr '\t' ' ' | awk '{print "INSERT INTO table_name VALUES ("$1",'\''"$2"'\'',"$3","$4","$5","$6",'\''"$7" "$8"'\'');";}'


PS:awk里转移单引号要用单引号括起来