PostgreSQL query output as a excel file

后端 未结 1 361
醉话见心
醉话见心 2021-01-22 02:39

I want to save the result of a psql query as an Excel file. ie, I have a table named company with 5 column. I want to execute the query,

SELECT column_1,
               


        
相关标签:
1条回答
  • 2021-01-22 02:46

    You could use csv to save your data and open/work with them in Excel. Syntax would be something like:

    Copy (SELECT column_1,
                 column_2,
          FROM company; 
         ) 
    To '/tmp/test.csv' With CSV;
    

    This query would run on server. You could also make usage of \query which is running on your client and saving the data locally. See also another SE question

    0 讨论(0)
提交回复
热议问题