Search Postgresql Archives

Re: Unique UUID value - PostgreSQL 9.2

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux