On Tue, 2009-10-20 at 11:00 +0200, Peter J. Holzer wrote:
> On 2009-10-20 15:54:30 +0800, Tim Bowden wrote:
> > On Tue, 2009-10-20 at 18:07 +1100, Ron Savage wrote:
> > > Hi Folks
> 
> [for those who don't know the sqlplus (or dbish) spool command: It's
> similar to the Unix tee(1) command: It copies all output which would
> normally go onto the screen into a file.

Hmm.  My understanding of spool/sqlplus just went up considerably ;-)

> 
> > > If it does, I can't see it in the Ref Man # 1.
> > > 
> > > Any ideas?
> > > 
> > 
> > copy.  Note there is both an sql copy command and a psql copy command.
> 
> I don't think so:
> 
> Input/Output
>   \copy ...              perform SQL COPY with data stream to the client host
> 
> And the postgresql copy command does something very different.
> 
>   \o [FILE]              send all query results to file or |pipe
> 
> is more like spool, but there are two important differences:
> 
>  1) it writes the results *only* to the file, not the screen.
>  2) it affects only the results, not the commands.
> 
> You should be able to get around the first limitation by invoking 
> \o |tee file
> but I don't see any way around the second.
> 
>         hp
> 

Ah yes, not quite the same at all.  And interesting use of \o.

If all you want to do is get the raw data from a query into a file then
copy is a handy and simple solution (which may or may not fit the
original problem).

http://www.postgresql.org/docs/8.4/interactive/sql-copy.html

Tim Bowden

Reply via email to