From: | "drum(dot)lucas(at)gmail(dot)com" <drum(dot)lucas(at)gmail(dot)com> |
---|---|
To: | Brent Wood <Brent(dot)Wood(at)niwa(dot)co(dot)nz> |
Cc: | James Keener <jim(at)jimkeener(dot)com>, "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, Postgres General <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Unique UUID value - PostgreSQL 9.2 |
Date: | 2016-03-14 22:51:04 |
Message-ID: | CAE_gQfUT4EUg75W8fsm+essC_w8GOWHXOMZpKOwnuEKtUmtnRA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 15 March 2016 at 11:44, Brent Wood <Brent(dot)Wood(at)niwa(dot)co(dot)nz> wrote:
> Not best practice but perhaps viable...
>
>
> In the target table add a serial datatype column as part of the unique
> constraint.
>
>
> Do not populate this column explicitly on insert, but have the db do it
> for you. It will allocate an incremental (unique) value automatically on
> insert.
>
>
> But I think your problem is more fundamental - if you genuinely have
> duplicate values in a column - there should not be a unique constraint on
> it. If it should be unique, then you should modify your insert data.
>
>
>
I Can't modify my insert data, because there's a PHP RANDOM CODE that does
exactly what I wanna do with the SQL - It generates a random but unique
value for the column "code" - So the customer will be able to have
duplicates values on that column
Today the PHP is already generating for example:
code_321525694417ad6b5f
So that is linked to another table (I can do that manually no problem)
I just need to know how can I do all of this
From | Date | Subject | |
---|---|---|---|
Next Message | David G. Johnston | 2016-03-14 23:05:04 | Re: Unique UUID value - PostgreSQL 9.2 |
Previous Message | Michael Paquier | 2016-03-14 22:46:28 | Re: Re: how to switch old replication Master to new Standby after promoting old Standby |