From: Guy Fraser <guy@incentre.net>
To: pgsql-sql@postgresql.org
Subject: Re: save sql result to file
Date: Fri, 24 Dec 2004 09:30:35 -0700
Message-ID: <1103905835.3474.2.camel@sigurd.incentre.net> (raw)
In-Reply-To: <20041224044445.16DE83384B@ws7-3.us4.outblaze.com>
References: <20041224044445.16DE83384B@ws7-3.us4.outblaze.com>
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.
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 using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: guy@incentre.net
Subject: Re: save sql result to file
In-Reply-To: <1103905835.3474.2.camel@sigurd.incentre.net>
* 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