From: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
---|---|
To: | "drum(dot)lucas(at)gmail(dot)com" <drum(dot)lucas(at)gmail(dot)com> |
Cc: | Brent Wood <Brent(dot)Wood(at)niwa(dot)co(dot)nz>, James Keener <jim(at)jimkeener(dot)com>, Postgres General <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Unique UUID value - PostgreSQL 9.2 |
Date: | 2016-03-14 23:05:50 |
Message-ID: | CAKFQuwaqXuVn4pvRiX_CtZ1aA-nQ0U1a_e0VHx2DvhkaSC-QPQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Mon, Mar 14, 2016 at 4:05 PM, David G. Johnston <
david(dot)g(dot)johnston(at)gmail(dot)com> wrote:
> On Mon, Mar 14, 2016 at 3:51 PM, drum(dot)lucas(at)gmail(dot)com <
> drum(dot)lucas(at)gmail(dot)com> wrote:
>
>> I just need to know how can I do all of this
>>
>
> You may have missed my prior email.
>
> You cannot COPY directly into the target table. You must copy to a
> staging table. You then insert from the staging table to the target table,
> listing every single column, and replacing those columns you want to change
> with some kind of expression.
>
> Basically:
>
> INSERT INTO targettable (col1, col2, col3)
> SELECT col1, col2 || '_' || nextval('sequence_name')::text, col3
> FROM stagingtable;
>
>
In theory an INSERT trigger might work too - but this is likely to be
simpler and faster.
David J.
From | Date | Subject | |
---|---|---|---|
Next Message | drum.lucas@gmail.com | 2016-03-15 01:41:41 | Re: Unique UUID value - PostgreSQL 9.2 |
Previous Message | David G. Johnston | 2016-03-14 23:05:04 | Re: Unique UUID value - PostgreSQL 9.2 |