jeudi 19 décembre 2019

Random default column value that rerolls on conflict

I have a column that I would like to default to a randomly generated int8 in a specified range. I would also like this column to be unique, so if a random value is generated that already exists, it should be rerolled.

So my question is what the most idiomatic way to do the above is in PostgreSQL, ideally with good performance and supporting bulk inserts.




Aucun commentaire:

Enregistrer un commentaire