Re: importing in sql - Mailing list pgsql-sql

From jmr@computing.com
Subject Re: importing in sql
Date
Msg-id 20000712.131933.71135909.jmr@computing.com
Whole thread Raw
In response to importing in sql  (Abdul Karim <karim@thehub.co.uk>)
List pgsql-sql
karim> The file has the following format
karim> 
karim> field2|field3|field4|field5|
karim> 
karim> Each field is separated by a | (pipe), How do I insert the sequence
karim> number before field2? I have like 30 files in this format and I need to
karim> import them in one table with each line having unique number.  Has
karim> anyone come across similar situation? any help would be greatly
karim> appreciated.

I'd create a new (temporary) table with only these 4 fields, and use
COPY to load it.  Then, insert the data into the real table from the
temp one.  Let postgres assign the serial numbers.
Something like this:    insert into <foo> (field2, field3, ...) select * from tmptable;
Then you can drop your temp table.

Jim Rowan
DCSI
jmr@computing.com


pgsql-sql by date:

Previous
From: "Ross J. Reedstrom"
Date:
Subject: Re: importing in sql
Next
From: Henry Lafleur
Date:
Subject: RE: join if there, blank if not