Re: How to generate unique hash-type id?

Поиск
Список
Период
Сортировка
От hubert depesz lubaczewski
Тема Re: How to generate unique hash-type id?
Дата
Msg-id 20100129115039.GA10982@depesz.com
обсуждение исходный текст
Ответ на How to generate unique hash-type id?  (Joe Kramer <cckramer@gmail.com>)
Ответы Re: How to generate unique hash-type id?  (Joe Kramer <cckramer@gmail.com>)
Список pgsql-general
On Fri, Jan 29, 2010 at 07:20:33PM +1100, Joe Kramer wrote:
> I need to generate unique id which is not guessable unlike
> serial(integer) type. I need an id in format like md5 hash of random
> number.

check this blogpost:
http://www.depesz.com/index.php/2007/06/25/random-text-record-identifiers/

> On top of that I need this id to be unique across multiple tables.

just add table id to the generated id.

for example: id "xxx" in table users, is globally unique (for your
database) when you write it: "users:xxx"

if, for some weird reason, you don't want to put table name on its own
in your key (why?) then just use some dictionary table, that will link
those keys with your table.

Best regards,

depesz

--
Linkedin: http://www.linkedin.com/in/depesz  /  blog: http://www.depesz.com/
jid/gtalk: depesz@depesz.com / aim:depeszhdl / skype:depesz_hdl / gg:6749007

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

Предыдущее
От: Alban Hertroys
Дата:
Сообщение: Re: Problem after installing triggering function
Следующее
От: Joe Kramer
Дата:
Сообщение: Re: How to generate unique hash-type id?