| From: | "Andy Shellam (Mailing Lists)" <andy(dot)shellam-lists(at)mailnetwork(dot)co(dot)uk> | 
|---|---|
| To: | Enrico <scotty(at)linuxtime(dot)it> | 
| Cc: | pgsql-admin(at)postgresql(dot)org | 
| Subject: | Re: Dump and Query | 
| Date: | 2006-12-27 12:14:57 | 
| Message-ID: | 459263C1.2040401@mailnetwork.co.uk | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-admin | 
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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Shoaib Mir | 2006-12-27 12:18:49 | Re: Dump and Query | 
| Previous Message | Shoaib Mir | 2006-12-27 08:46:25 | Re: About Monitoring Software |