How to Export SQL Query to TXT Using Command Line

前端 未结 1 795
面向向阳花
面向向阳花 2021-02-09 03:18

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条回答
  • 2021-02-09 03:33

    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'
    
    0 讨论(0)
提交回复
热议问题