Copy postgres query results to file Oct 23, 2017 COPY (query) TO 'file'; COPY (select * from users) TO '/tmp/users.csv'; https://www.postgresql.org/docs/9.2/static/sql-copy.html