pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: jmr@computing.com
To: karim@thehub.co.uk
Cc: pgsql-sql@postgresql.org
Subject: Re: importing in sql
Date: Wed, 12 Jul 2000 13:19:33 -0500 (CDT)
Message-ID: <20000712.131933.71135909.jmr@computing.com> (raw)
In-Reply-To: <396A481C.D8D4E21@thehub.co.uk>
References: <396A481C.D8D4E21@thehub.co.uk>

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



view thread (3+ messages)

Message-ID: <20000712.131933.71135909.jmr@computing.com>
Permalink:  ../20000712.131933.71135909.jmr@computing.com/
Also on:    postgresql.org/message-id/20000712.131933.71135909.jmr@computing.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: jmr@computing.com, karim@thehub.co.uk
  Subject: Re: importing in sql
  In-Reply-To: <20000712.131933.71135909.jmr@computing.com>
  References: <396A481C.D8D4E21@thehub.co.uk> <20000712.131933.71135909.jmr@computing.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox