Re: importing in sql

From: jmr(at)computing(dot)com
To: karim(at)thehub(dot)co(dot)uk
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: importing in sql
Date: 2000-07-12 18:19:33
Message-ID: 20000712.131933.71135909.jmr@computing.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)computing(dot)com

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Henry Lafleur 2000-07-12 18:51:24 RE: join if there, blank if not
Previous Message Ross J. Reedstrom 2000-07-12 17:55:57 Re: importing in sql