How to save PostgreSQL psql query output to a CSV file
https://www.postgresql.org/docs/current/static/sql-copy.html
=> \copy (select * from audityear) TO '/tmp/test1.csv' (format CSV);
=> \copy (select * from audityear) TO '/tmp/test1.csv' (format CSV, delimiter ',');
=> \copy (select * from audityear) TO '/tmp/test1.csv' (format CSV, delimiter ',', HEADER);
OR
=> \copy (select * from audityear) TO '/tmp/test1.csv' (format TEXT);
=> \copy (select * from audityear) TO '/tmp/test1.csv' (format TEXT, delimiter ',');
OR
=> \copy (select * from audityear) TO '/tmp/test1.csv' WITH CSV
=> \copy (select * from audityear) TO '/tmp/test1.csv' WITH CSV HEADER;
https://www.postgresql.org/docs/current/static/sql-copy.html
=> \copy (select * from audityear) TO '/tmp/test1.csv' (format CSV);
=> \copy (select * from audityear) TO '/tmp/test1.csv' (format CSV, delimiter ',');
=> \copy (select * from audityear) TO '/tmp/test1.csv' (format CSV, delimiter ',', HEADER);
OR
=> \copy (select * from audityear) TO '/tmp/test1.csv' (format TEXT);
=> \copy (select * from audityear) TO '/tmp/test1.csv' (format TEXT, delimiter ',');
OR
=> \copy (select * from audityear) TO '/tmp/test1.csv' WITH CSV
=> \copy (select * from audityear) TO '/tmp/test1.csv' WITH CSV HEADER;
No comments:
Post a Comment