Don’t forget!

Without the semi-colon at the end of any statement the statement won’t execute…I always forget this one!

Connect to PSQL

psql -d <database_name> -U <user_with_DB_access_permissions>

Save Output to CSV

PSQL has the ‘\copy’ function that takes a SQL statement and saves the output to a range of file types, in this case CVS, to a directory you specify.

\copy (SELECT * Table1 ) To ‘/home/user1/reports/output1.csv’ WITH CVS;


Disclaimer: provided “AS IS” with no warranties and confer no rights