X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0C3203C82DA for ; Fri, 24 Dec 2004 16:30:43 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 97887-03 for ; Fri, 24 Dec 2004 16:30:39 +0000 (GMT) Received: from bach.ccinet.ab.ca (bach.ccinet.ab.ca [198.161.96.1]) by svr1.postgresql.org (Postfix) with ESMTP id 02BCD3C82C4 for ; Fri, 24 Dec 2004 16:30:37 +0000 (GMT) Received: from guy-pc.incentre.net (guy-pc.incentre.net [206.75.213.195] (may be forged)) by bach.ccinet.ab.ca (8.12.9p2/8.12.9) with ESMTP id iBOGh3HL058937 for ; Fri, 24 Dec 2004 09:43:03 -0700 (MST) (envelope-from guy@incentre.net) Subject: Re: save sql result to file From: Guy Fraser Reply-To: guy@incentre.net To: pgsql-sql@postgresql.org In-Reply-To: <20041224044445.16DE83384B@ws7-3.us4.outblaze.com> References: <20041224044445.16DE83384B@ws7-3.us4.outblaze.com> Content-Type: text/plain Organization: The Internet Centre Date: Fri, 24 Dec 2004 09:30:35 -0700 Message-Id: <1103905835.3474.2.camel@sigurd.incentre.net> Mime-Version: 1.0 X-Mailer: Evolution 2.0.2 (2.0.2-3) Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.629 tagged_above=0 required=5 tests=URIBL_SBL X-Spam-Level: X-Archive-Number: 200412/154 X-Sequence-Number: 19774 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.