Re: export a select result in a file ?

From: Scott Marlowe <smarlowe(at)g2switchworks(dot)com>
To: ctobini <ctemp2(at)free(dot)fr>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: export a select result in a file ?
Date: 2005-10-04 16:26:03
Message-ID: 1128443162.29347.119.camel@state.g2switchworks.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, 2005-10-04 at 07:00, ctobini wrote:
> Hello,
>
> I don't find in the PostgreSQL doc how to export a select result in a
> text file.

If you want to get the data without being IN psql (like in an automated
script) you can use the -tc switches ("t"uples only, run this
"c"ommand):

psql dbname -tc "select yabba from dabba where doo=1" > myfile.dat

If you're in psql, use \o for output. \i does the same thing for input
from a file.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jim C. Nasby 2005-10-04 17:36:28 Re: [INTERFACES] how to monitor dead connections to postgresql database
Previous Message Sven Willenberger 2005-10-04 16:22:52 Re: strip zeros from fractional part