Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 0D6F51337B9D for ; Tue, 5 Oct 2010 17:50:50 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 36705-02 for ; Tue, 5 Oct 2010 20:50:43 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail-bw0-f46.google.com (mail-bw0-f46.google.com [209.85.214.46]) by mail.postgresql.org (Postfix) with ESMTP id 178EC1337B71 for ; Tue, 5 Oct 2010 17:50:41 -0300 (ADT) Received: by bwz11 with SMTP id 11so4871618bwz.19 for ; Tue, 05 Oct 2010 13:50:40 -0700 (PDT) Received: by 10.204.84.230 with SMTP id k38mr8894587bkl.160.1286311840511; Tue, 05 Oct 2010 13:50:40 -0700 (PDT) Received: from Craig-Jamess-MacBook-Pro.local (wsip-70-167-124-126.sd.sd.cox.net [70.167.124.126]) by mx.google.com with ESMTPS id s34sm5334885bkk.13.2010.10.05.13.50.38 (version=SSLv3 cipher=RC4-MD5); Tue, 05 Oct 2010 13:50:39 -0700 (PDT) Message-ID: <4CAB8F9B.70401@emolecules.com> Date: Tue, 05 Oct 2010 13:50:35 -0700 From: Craig James User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.9) Gecko/20100915 Thunderbird/3.1.4 MIME-Version: 1.0 To: pgsql-admin@postgresql.org Subject: Re: restore References: <4CAB698B.4040402@iii.com> In-Reply-To: <4CAB698B.4040402@iii.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201010/48 X-Sequence-Number: 35789 On 10/5/10 11:08 AM, Dinesh Bhandary wrote: > Hi All, > > Is there an easy way to restore to a new table where the column name have been changed but data remains the same? > For example I am trying to restore from existing system, table1(col1) to table1(col2) and it is erroring out on the new column name even though it is a data only restore. I was just wondering if there is a quick way to bypass this. Let me know. If your data file is plain text with a COPY or INSERT commands, do this using psql: begin; alter table1 rename col2 to col1; \i datafile.sql alter table1 rename col1 to col2; commit; Craig