Saving an output of PostgreSQL query to a text file
Posted on August 14th, 2009 by linux
In PostgreSQL database it is possible to save / export and results of a database query to a simple text file. By default all query result are displayed on the screen. This default behavior can be overwritten by \o command:
postresql=> \o /path/to/your/text/file.txt
postresql=> postgresql query ( here place your query )
postresql=> \o ( set back the default output behavior )