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里转移单引号要用单引号括起来

你可能感兴趣的:(sql,mysql)