标签: unix
我想使用unix脚本将sql查询的结果导出到CSV文件(逗号分隔)。请帮忙
答案 0 :(得分:1)
试试这个(来源:Export Data From Database to CSV File)
mysql -u user -p pass database -B -e "select * from \'person\';" | sed 's/\t/","/g;s/^/"/;s/$/"/;s/\n//g' > filename.csv