Re: Unique UUID value - PostgreSQL 9.2 - Mailing list pgsql-general

From David G. Johnston
Subject Re: Unique UUID value - PostgreSQL 9.2
Date
Msg-id CAKFQuwaqXuVn4pvRiX_CtZ1aA-nQ0U1a_e0VHx2DvhkaSC-QPQ@mail.gmail.com
Whole thread Raw
In response to Re: Unique UUID value - PostgreSQL 9.2  ("David G. Johnston" <david.g.johnston@gmail.com>)
Responses Re: Unique UUID value - PostgreSQL 9.2  ("drum.lucas@gmail.com" <drum.lucas@gmail.com>)
List pgsql-general
On Mon, Mar 14, 2016 at 4:05 PM, David G. Johnston <david.g.johnston@gmail.com> wrote:
On Mon, Mar 14, 2016 at 3:51 PM, drum.lucas@gmail.com <drum.lucas@gmail.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.
 

pgsql-general by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: Unique UUID value - PostgreSQL 9.2
Next
From: "drum.lucas@gmail.com"
Date:
Subject: Re: Unique UUID value - PostgreSQL 9.2