Re: Unique UUID value - PostgreSQL 9.2

Поиск
Список
Период
Сортировка
От drum.lucas@gmail.com
Тема Re: Unique UUID value - PostgreSQL 9.2
Дата
Msg-id CAE_gQfUT4EUg75W8fsm+essC_w8GOWHXOMZpKOwnuEKtUmtnRA@mail.gmail.com
обсуждение исходный текст
Ответ на Unique UUID value - PostgreSQL 9.2  ("drum.lucas@gmail.com" <drum.lucas@gmail.com>)
Ответы Re: Unique UUID value - PostgreSQL 9.2  ("David G. Johnston" <david.g.johnston@gmail.com>)
Список pgsql-general


On 15 March 2016 at 11:44, Brent Wood <Brent.Wood@niwa.co.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

В списке pgsql-general по дате отправления:

Предыдущее
От: Michael Paquier
Дата:
Сообщение: Re: Re: how to switch old replication Master to new Standby after promoting old Standby
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: Unique UUID value - PostgreSQL 9.2