Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Unique Date/Time
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
![]() |
![]() |