| From: | John DeSoi <desoi(at)pgedit(dot)com> |
|---|---|
| To: | Tino Wildenhain <tino(at)wildenhain(dot)de> |
| Cc: | Riaan van der Westhuizen <riaan(at)huizensoft(dot)co(dot)za>, Postgresql-General <pgsql-general(at)postgresql(dot)org> |
| Subject: | Re: GUID for postgreSQL |
| Date: | 2005-07-27 20:32:27 |
| Message-ID: | 457ABBAB-4595-4B61-A9E3-51ED73CE4277@pgedit.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
On Jul 27, 2005, at 4:49 AM, Tino Wildenhain wrote:
> I'd create a sequence:
>
> CREATE SEQUENCE global_unique_id_seq;
>
> and a function:
>
> CREATE OR REPLACE FUNCTION newid()
> RETURNS text AS
> $BODY$ SELECT nextval('global_unique_id_seq')::text; $BODY$
> LANGUAGE 'sql' VOLATILE;
>
>
> now every call to newid() returns a garantied unique id for
> say the next 18446744073709551616 calls.
> Of course you can obfuscate the ID even more using
> md5, include servername and so on, but this will not improve
> security in any way (unless you mix data with 2nd database)
This is not really a viable replacement for a GUID == globally unique
identifier. Here global means that if I use the application in
multiple databases, I'm guaranteed that no two identifiers will be
the same. Using a sequence will only support uniqueness for a single
database.
Best,
John DeSoi, Ph.D.
http://pgedit.com/
Power Tools for PostgreSQL
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Jonathan Villa | 2005-07-27 20:43:51 | Re: Upgrading from 7.1 |
| Previous Message | Brian Wong | 2005-07-27 20:31:28 | Re: DELETE with JOIN syntax |