| From: | Thom Brown <thombrown(at)gmail(dot)com> |
|---|---|
| To: | pgsql-general(at)postgresql(dot)org |
| Subject: | Generating random unique alphanumeric IDs |
| Date: | 2009-08-16 11:07:27 |
| Message-ID: | bddc86150908160407y4719cc54gc1604dacfaa5439b@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
Does anyone know a way to generate a random and unique lowercase
alphanumeric ID (preferably without using 0, 1, o or i to prevent problems
with users manually typing the ID) using SQL without resorting to a
prerendered table or using GUIDs.
For example, if I were to ask for an ID of 5 characters, something like the
following would be returned:
hn21o
8sp2j
9wwun
m7z02
Notice that I don't mean hexadecimal values either. This would preferrably
not resort to trying to generate the ID, then checking for a clash, and if
there is one, do it again, although that could do as I can't think of how
the ideal solution of a ID hashing algorithm would be possible.
Any ideas?
Thanks
Thom
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Alban Hertroys | 2009-08-16 11:09:00 | Re: A history procedure that prevents duplicate entries |
| Previous Message | Sam Mason | 2009-08-16 11:06:07 | Re: [Q] parsing out String array |