select into without creating new table

Started by Paulover 23 years ago5 messagesgeneral
Jump to latest
#1Paul
nomail@nomail.com

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.

Any help would be appreciated!

-----------== Posted via Newsfeed.Com - Uncensored Usenet News ==----------
http://www.newsfeed.com The #1 Newsgroup Service in the World!
-----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19 Servers =-----

#2Lee Harr
missive@frontiernet.net
In reply to: Paul (#1)
Re: select into without creating new table

In article <3daff3bf_2@goliath2.newsgroups.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);

#3Patrick Fiche
patrick.fiche@aqsacom.com
In reply to: Lee Harr (#2)
Re: select into without creating new table

INSERT INTO newtable ( col1, col2 ) SELECT cola, colb FROM oldtable

-----Original Message-----
From: pgsql-general-owner@postgresql.org
[mailto:pgsql-general-owner@postgresql.org]On Behalf Of Paul
Sent: Friday, October 18, 2002 1:45 PM
To: pgsql-general@postgresql.org
Subject: [GENERAL] select into without creating new table

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.

Any help would be appreciated!

-----------== Posted via Newsfeed.Com - Uncensored Usenet News ==----------
http://www.newsfeed.com The #1 Newsgroup Service in the World!
-----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19 Servers
=-----

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo@postgresql.org)

#4Ian Harding
ianh@tpchd.org
In reply to: Patrick Fiche (#3)
Re: select into without creating new table

insert into oldtable (col1, col2) select colx, coly from othertable

Ian A. Harding
Programmer/Analyst II
Tacoma-Pierce County Health Department
(253) 798-3549
iharding@tpchd.org

"Paul" <nomail@nomail.com> 10/18/02 04:44AM >>>

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.

Any help would be appreciated!

-----------== Posted via Newsfeed.Com - Uncensored Usenet News ==----------
http://www.newsfeed.com The #1 Newsgroup Service in the World!
-----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19 Servers =-----

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo@postgresql.org)

#5Shridhar Daithankar
shridhar_daithankar@persistent.co.in
In reply to: Paul (#1)
Re: select into without creating new table

On 18 Oct 2002 at 13:44, Paul wrote:

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

Try insert into newtable select * from oldtable;

See insert syntax for more details..

HTH

Bye
Shridhar

--
lighthouse, n.: A tall building on the seashore in which the government
maintains a lamp and the friend of a politician.