Re: SELECT to an external file

From: Oliver Elphick <olly(at)lfix(dot)co(dot)uk>
To: Mário Gamito <gamito(at)netual(dot)pt>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: SELECT to an external file
Date: 2004-08-24 17:13:59
Message-ID: 1093367639.15248.11.camel@linda
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, 2004-08-24 at 18:08, Mário Gamito wrote:
> Hi,
>
> How can i draw the results of a SELECT in to a file in the filesystem ?

Using psql:

1. \o /path/to/file
SELECT ... ;
\o

2. psql -d my_database -c "SELECT ... " >/path/to/file

--
Oliver Elphick olly(at)lfix(dot)co(dot)uk
Isle of Wight http://www.lfix.co.uk/oliver
GPG: 1024D/A54310EA 92C8 39E7 280E 3631 3F0E 1EC0 5664 7A2F A543 10EA
========================================
"I saw in the night visions, and, behold, one like the
Son of man came with the clouds of heaven, and came to
the Ancient of days, and they brought him near before
him. And there was given him dominion, and glory, and
a kingdom, that all people, nations, and languages,
should serve him; his dominion is an everlasting
dominion, which shall not pass away, and his kingdom
that which shall not be destroyed."
Daniel 7:13,14

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David Wheeler 2004-08-24 17:14:07 Re: UTF-8 and LIKE vs =
Previous Message Devrim GUNDUZ 2004-08-24 17:12:39 Re: SELECT to an external file