How to Export SQL Query to TXT Using Command Line

淺唱寂寞╮ 提交于 2019-12-04 10:51:12

问题


I want to export select * from table results to a text file from the command line in linux. How should I do this?

Thanks, Jean


回答1:


look at link

you only need to add this to the query

select * from table INTO OUTFILE '/tmp/myfilename.txt'

you can improve this to csv file (using it in excel latter)

like :

INTO OUTFILE '/tmp/myfilename.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'


来源:https://stackoverflow.com/questions/4243610/how-to-export-sql-query-to-txt-using-command-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!