Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

Save PL/pgSQL output from PostgreSQL to a CSV file

>psql dbname
psql>f ','
psql>a
psql>o '/tmp/output.csv'
psql>SELECT * from users;
psql>q

----------------------------------
COPY (SELECT * from users) To '/tmp/output.csv' With CSV;

-----------------------------------------
psql -d dbname -t -A -F"," -c "select * from users" > output.csv


Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Save #output #PostgreSQL #CSV #file
ADD COMMENT
Topic
Name
5+8 =