Re: Copy query results to a file - Mailing list pgsql-novice

From Oliver Elphick
Subject Re: Copy query results to a file
Date
Msg-id 1092082157.13140.342.camel@linda
Whole thread Raw
In response to Copy query results to a file  (Eduardo Vázquez Rodríguez<evazquez@insys-corp.com.mx>)
List pgsql-novice
On Mon, 2004-08-09 at 20:00, Eduardo Vázquez Rodríguez wrote:
> My purpose is to copy the results of a query to a file, how I do that?
>
> Thanks in advenced

$ psql -d mydb
mydb=# \o /path/to/file
mydb=# select ...;
mydb=# \o


In that case /path/to/file must be writable by the backend.

Alternatively,

$ psql -d mydb -c "select ..." > /path/to/file

If you are using Windows, the syntax of the latter method may be
different.

--
Oliver Elphick                                          olly@lfix.co.uk
Isle of Wight                              http://www.lfix.co.uk/oliver
GPG: 1024D/A54310EA  92C8 39E7 280E 3631 3F0E  1EC0 5664 7A2F A543 10EA
                 ========================================
     "Be still before the LORD and wait patiently for him;
      do not fret when men succeed in their ways, when they
      carry out their wicked schemes."
                            Psalms 37:7


pgsql-novice by date:

Previous
From: Eduardo Vázquez Rodríguez
Date:
Subject: Copy query results to a file
Next
From: Thiemo Kellner
Date:
Subject: Re: [GENERAL] Error >>syntax error<< at >>$1<< at character 53