I want to export query result in csv file. I used query select * from entity
COPY (select * from entity) TO ‘D:/text.csv’ WITH DELIMITER AS ‘|’ CSV HEADER;
and it workd.. But I want to know if I can do it using spool command like we do it in oracle..
I want to export query result in csv file. I used query select *
Share
PostgreSQL doesn’t have a SPOOL command. You can direct output to a file using COPY (as you’ve discovered) or by using psql. Psql is a command-line tool. It’s not a re-implementation of Oracle’s SPOOL.
From the OS prompt
You might have to specify the username and database name, depending on how your login is set up.
From the psql prompt
There are options to control the output. See the -F and -R options, especially.