pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andy Shellam (Mailing Lists) <andy.shellam-lists@mailnetwork.co.uk>
To: Enrico <scotty@linuxtime.it>
Cc: pgsql-admin@postgresql.org
Subject: Re: Dump  and Query
Date: Wed, 27 Dec 2006 12:14:57 +0000
Message-ID: <459263C1.2040401@mailnetwork.co.uk> (raw)
In-Reply-To: <20061227140530.094fc4d3.scotty@linuxtime.it>
References: <20061227140530.094fc4d3.scotty@linuxtime.it>

Hi Enrico,

The following command will get you a text file of your result-set:

# echo "SELECT customer_id, first_name, sur_name FROM 
users;"|/usr/local/pgsql/bin/psql -U [username] -d [database] > myfile.txt
# cat myfile.txt

 customer_id | first_name | sur_name
-------------+------------+----------
 CUS0000002  | Andy       | Shellam 


Or you can dump a specific table:

# /usr/local/pgsql/bin/pg_dump --table=[tablename] [database]

Regards,

Andy.

Enrico wrote:
> Is there any way to make a dump from a query?
>
> For example if my query is:
>
> select field1,field2 from table
>
> Does it exist a shell command like pg_dump --QUERY myquery -f myfile?
>
> Have a nice day
> Enrico
>
>   


-- 
Andy Shellam
NetServe Support Team

the Mail Network
"an alternative in a standardised world"

p: +44 (0) 121 288 0832/0839
m: +44 (0) 7818 000834




view thread (5+ messages)  latest in thread

Message-ID: <459263C1.2040401@mailnetwork.co.uk>
Permalink:  ../459263C1.2040401@mailnetwork.co.uk/
Also on:    postgresql.org/message-id/459263C1.2040401@mailnetwork.co.uk

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: andy.shellam-lists@mailnetwork.co.uk, scotty@linuxtime.it
  Subject: Re: Dump  and Query
  In-Reply-To: <459263C1.2040401@mailnetwork.co.uk>
  References: <20061227140530.094fc4d3.scotty@linuxtime.it> <459263C1.2040401@mailnetwork.co.uk>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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