pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Export to file
4+ messages / 4 participants
[nested] [flat]

* Export to file
@ 2003-09-09 16:15  Marvin <magosoft@gmx.net>
  0 siblings, 3 replies; 4+ messages in thread

From: Marvin @ 2003-09-09 16:15 UTC (permalink / raw)
  To: pgsql-admin

Hi,
There is a way to export the result 
of a query into an external DBF or TXT table?

Thank you,


MAGO

Attachments:

IMSTP.gif (image/gif, 494B) download view image
^ permalink raw reply [nested|flat] 4+ messages in thread

* Re: Export to file
@ 2003-09-10 09:56  Oliver Elphick <olly@lfix.co.uk>
  parent: Marvin <magosoft@gmx.net>
  2 siblings, 0 replies; 4+ messages in thread

From: Oliver Elphick @ 2003-09-10 09:56 UTC (permalink / raw)
  To: Marvin <magosoft@gmx.net>; +Cc: pgsql-admin

On Tue, 2003-09-09 at 17:15, Marvin wrote:
> Hi,
> There is a way to export the result 
> of a query into an external DBF or TXT table?
> 

You can't write out a DBF file without some other software, but writing
a text file is easy.  In an interactive session of psql, use:

        \o filename

You probably also want:
        
        \pset format unaligned
        \pset fieldsep ','
        \t

That would produce a text file with comma-separated values and no
headings.

-- 
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight, UK                             http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839  932A 614D 4C34 3E1D 0C1C
                 ========================================
     "Draw near to God and he will draw near to you.  
      Cleanse your hands, you sinners; and purify your  
      hearts, you double minded."       James 4:8 




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Export to file
@ 2003-09-10 12:16  A.Bhuvaneswaran <bhuvan@symonds.net>
  parent: Marvin <magosoft@gmx.net>
  2 siblings, 0 replies; 4+ messages in thread

From: A.Bhuvaneswaran @ 2003-09-10 12:16 UTC (permalink / raw)
  To: Marvin <magosoft@gmx.net>; +Cc: pgsql-admin


psql=> \o filename.txt
psql=> select query;
psql=> \o

regards, 
bhuvaneswaran

On Tue, 9 Sep 2003, Marvin wrote:

> Hi,
> There is a way to export the result 
> of a query into an external DBF or TXT table?
> 
> Thank you,
> 
> 
> MAGO




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Export to file
@ 2003-09-10 15:17  Reece Hart <rkh@gene.COM>
  parent: Marvin <magosoft@gmx.net>
  2 siblings, 0 replies; 4+ messages in thread

From: Reece Hart @ 2003-09-10 15:17 UTC (permalink / raw)
  To: Marvin <magosoft@gmx.net>; +Cc: pgsql-admin

On Tue, 2003-09-09 at 09:15, Marvin wrote:
> 
> There is a way to export the result 
> of a query into an external DBF or TXT table?
> 

I often do something like this:
$ psql -At -c 'select ... where ...'

This is so handy, that I have a (bash) shell alias for it:
$ alias csbq='psql -UPUBLIC -dcsb -At -c'
then
$ csbq 'select ...'

-Reece

-- 
Reece Hart, Ph.D.                       rkh@gene.com, http://www.gene.com/
Genentech, Inc.                         650/225-6133 (voice), -5389 (fax)
Bioinformatics and Protein Engineering
1 DNA Way, MS-93                        http://www.in-machina.com/~reece/
South San Francisco, CA  94080-4990     reece@in-machina.com, GPG: 0x25EC91A0



^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2003-09-10 15:17 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-09-09 16:15 Export to file Marvin <magosoft@gmx.net>
2003-09-10 09:56 ` Oliver Elphick <olly@lfix.co.uk>
2003-09-10 12:16 ` A.Bhuvaneswaran <bhuvan@symonds.net>
2003-09-10 15:17 ` Reece Hart <rkh@gene.COM>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox