Re: select into without creating new table

From: Lee Harr <missive(at)frontiernet(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: select into without creating new table
Date: 2002-10-18 23:15:23
Message-ID: aoq4mb$19n3$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

In article <3daff3bf_2(at)goliath2(dot)newsgroups(dot)com>, Paul wrote:
> Hi,
>
> How can I select data from table into an existing table. I've redesigned
> some tables and thus want my data to be copied from the old table to the new
> one. Since the column order, names (and the number of columns) is not equal
> i thought of using:
>
> select column1,column2 into newtable from oldtable
>
> THis however leads to an error that states that the table exists already.
> Deleting the table is no option for me since I want the data to be in the
> table with the new structure.
>

INSERT INTO newtable (SELECT column1, column2 FROM oldtable);

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2002-10-19 00:46:34 Re: cvs retrieval of earthdistance
Previous Message Bruno Wolff III 2002-10-18 22:39:43 cvs retrieval of earthdistance