| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | "Brian Johnson" <bjohnson(at)jecinc(dot)on(dot)ca> |
| Cc: | pgsql-novice(at)postgresql(dot)org |
| Subject: | Re: Insert from CSV (comma separated values) file |
| Date: | 2003-01-16 05:14:07 |
| Message-ID: | 11835.1042694047@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-novice |
"Brian Johnson" <bjohnson(at)jecinc(dot)on(dot)ca> writes:
> I need to insert some values from a CSV file. It's a little more
> complicated than that since I have to do a SELECT query (from one
> table) on one of the values to get the proper value for the INSERT
> query (into another table)
Doesn't seem that hard. Insert the raw data into a temp table using
a command along the lines of
COPY TO temp_table ... WITH DELIMITER ','
and then construct the final result rows with something like
INSERT INTO dest_table
SELECT ..., (SELECT ... FROM other_table), ... FROM temp_table
If that's not enough to get you going, let's see more details.
regards, tom lane
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Thilo Hille | 2003-01-16 10:37:44 | VACUUM ANALYSE... |
| Previous Message | Brian Johnson | 2003-01-16 03:50:40 | Insert from CSV (comma separated values) file |