Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: GUID as primary key

Re: GUID as primary key

From: Billy <vslabs_at_onwe.co.za>
Date: 20 Jun 2005 05:14:30 -0700
Message-ID: <1119269670.182088.34550@g47g2000cwa.googlegroups.com>


Andreas Mosmann wrote:
> Hi,
>
> <Oracle 9.2i>
> I got 2 questions:
>
> Is there a package (or something else) where I can get a GUID from the
> oracle system? (something like SELECT DBMS_GUID.GenerateGUID FROM DUAL)

SQL> select sys_guid() from dual;

SYS_GUID()



F9F937F446ADEFD2E03001C450532277
> We want to use GUID for all Rows in the Database. We can do this by the
> application, but sometimes (Triggers etc.) it would be useful to
> generate a GUID in the database directly.

Why not use a sequence instead? Sequences are tailor made for scaling with concurrent usage. I doubt that SYS_GUID is.

> You can give a column in a table a default value. How can I give oracle
> a function instead of a plain value so that this function is called
> everytime a new row is generated?

Why not simply code it in the INSERT statement? Is it honestly such a good idea to hide the sequence number from the INSERT? What does it buy you? What does it cost you in the long run ito maintenance when a developer touches that code?

I've heard some good arguments for why not obfuscate the use of sequences with the counter arguments not being that strong.

--
Billy
Received on Mon Jun 20 2005 - 07:14:30 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US