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: Unique Date/Time

Re: Unique Date/Time

From: Chris Hamilton <toneczar_at_erols.com>
Date: 1998/04/07
Message-ID: <01bd6228$9458bfa0$73344b9b@chrish.hq.usace.army.mil>#1/1

Igor Sereda <sereda_at_spb.runnet.ru> wrote ...  

> I have somewhat similar problem. I have a DATE type field as a primary
> key field.
> When rows are being inserted, SYSDATE is used to fill this field.
> I fear that more than one insertion can happen within one second
> and unique constraint will be violated.
> Now i'm trying to find a reasonable solution and
> any help will be welcome.

I think the only reasonable solution is to NOT use a date field as a primary key. Use a sequence-generated numbers instead.

You could still come up with a scheme to make the date field unique. One group I know of used a C function to call the OS and get time down to fractions of seconds, but I don't know the details of how they did it. And you still cannot 100% guarantee uniqueness.

If you CAN get the date field unique, you could put a UNIQUE constraint on it, but don't use it as a PRIMARY KEY. Keep it simple and guaranteed unique.  

Chris



Chris Hamilton -- toneczar_at_erols.com
City of Washington Pipe Band
http://www.serve.com/cowpb/chamilton.html Received on Tue Apr 07 1998 - 00:00:00 CDT

Original text of this message

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