Re: save sql result to file

From: Guy Fraser <guy(at)incentre(dot)net>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: save sql result to file
Date: 2004-12-24 16:30:35
Message-ID: 1103905835.3474.2.camel@sigurd.incentre.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Gregory S. Williamson 2004-12-24 22:18:42 Re: commit inside plpgsql function
Previous Message william lim 2004-12-24 04:44:45 save sql result to file