pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
save sql result to file
2+ messages / 2 participants
[nested] [flat]

* save sql result to file
@ 2004-12-24 04:44 william lim <wei.liang@lycos.com>
  2004-12-24 16:30 ` Re: save sql result to file Guy Fraser <guy@incentre.net>
  0 siblings, 1 reply; 2+ messages in thread

From: william lim @ 2004-12-24 04:44 UTC (permalink / raw)
  To: pgsql-sql

how to save sql result to a text file in database-backup format?
I want to backup a portion of data from my query to files and can do restore from them.

Thanks

William

___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.
-- 
_______________________________________________
Find what you are looking for with the Lycos Yellow Pages
http://r.lycos.com/r/yp_emailfooter/http://yellowpages.lycos.com/default.asp?SRC=lycos10




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

* Re: save sql result to file
  2004-12-24 04:44 save sql result to file william lim <wei.liang@lycos.com>
@ 2004-12-24 16:30 ` Guy Fraser <guy@incentre.net>
  0 siblings, 0 replies; 2+ messages in thread

From: Guy Fraser @ 2004-12-24 16:30 UTC (permalink / raw)
  To: pgsql-sql

Off the top of my head:

psql -c "select .... into dump_table from old_table .... ;" database
pg_dump -t dump_table -f dump_table.tmp database
sed -e "s/dump_table/table_name/g" dump_table.tmp >table_name.sql
rm dump_table.tmp

You should now have a file called table_name.sql with the stuff 
required to create a new table called table_name with the data 
from your query.

On Thu, 2004-23-12 at 20:44 -0800, william lim wrote: 
> how to save sql result to a text file in database-backup format?
> I want to backup a portion of data from my query to files and can do restore from them.
> 
> Thanks
> 
> William
> 
> ___________________________________________________________
> Sent by ePrompter, the premier email notification software.
> Free download at http://www.ePrompter.com.




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


end of thread, other threads:[~2004-12-24 16:30 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-12-24 04:44 save sql result to file william lim <wei.liang@lycos.com>
2004-12-24 16:30 ` Guy Fraser <guy@incentre.net>

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