2

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,
       column_2,
     FROM company; 

And I just want to save the result of this query as a Excel file. Is it possible in PostgreSQL? If yes then please explain it.

Thank you......

1 Answer 1

4

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.