From: | "Keith Worthington" <keithw(at)narrowpathinc(dot)com> |
---|---|
To: | "PostgreSQL Novice" <pgsql-novice(at)postgresql(dot)org> |
Subject: | Copy data from table to table |
Date: | 2005-04-27 13:16:09 |
Message-ID: | 20050427130641.M82263@narrowpathinc.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
Hi All,
I can not think of a way to copy data directly betweeen two tables.
I can only think of two ways to copy the data indirectly.
Method 1: Write a function that loops through the results of a select query
running individual inserts for each record.
Method 2: Use SELECT INTO to put the desired data in a temporoary table; then
use COPY to store the data in a file and finally use COPY to read the data
from the file to the target table.
I have implemented the first method for situations where the source data ends
up in multiple tables but I want to check with all of you prior to creating a
function to do this for a single target table.
As a curious point of information I worked with a database once that allowed
you to SELECT INTO an existing table. It was handy.
Kind Regards,
Keith
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Fuhr | 2005-04-27 13:34:44 | Re: Copy data from table to table |
Previous Message | Tom Lane | 2005-04-27 03:29:22 | Re: Poor-man's enumeration type |