Re: HOWTO - Random character generation for primary key

From: Jean-Michel POURE <jm(dot)poure(at)freesurf(dot)fr>
To: postgres(at)vrane(dot)com
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: HOWTO - Random character generation for primary key
Date: 2002-05-02 11:01:22
Message-ID: 200205021301.22897.jm.poure@freesurf.fr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-general

Le Jeudi 2 Mai 2002 12:13, postgres(at)vrane(dot)com a écrit :
> > Le Jeudi 2 Mai 2002 11:30, postgres(at)vrane(dot)com a écrit :
> > > Untrue. I am using email addresses
> > > as primary keys in a table. Where
> > > did you get that information?
> >
> > Sorry, I did not mean that of course. I posted this small howto in reply
> > to a mail. It shows how to create a VACHAR PRIMARY KEY with unique random
> > values.
> > On 10 character lenght, there is approximatively one chance out of 26^10
> > to have a similar value. If you add a string timestamp, like
> > "20020501_1153_" in front of the random value, it is very likely that
> > this value will be UNIQUE in the word:
>
> In the real world "very likely" is not good enough. Can you gurantee
> 'uniqueness'?

A timestamp (ex: 20020501_1258) followed by PLpgSQL function
random_string(200) value should provide a unique signature. What do you
think? Alternatively, could we use the crypto package to generate a unique
signature?

Cheers,
Jean-Michel POURE

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Judy Jecelin 2002-05-02 13:19:57 unsubscribe
Previous Message Jean-Michel POURE 2002-05-02 09:58:53 Re: HOWTO - Random character generation for primary key

Browse pgsql-general by date

  From Date Subject
Next Message Thierry Besancon 2002-05-02 11:28:13 hexadecimal values
Previous Message Jean-Michel POURE 2002-05-02 09:58:53 Re: HOWTO - Random character generation for primary key