| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.server -> Re: Building a primary key
Tim Witort <trw_at_medicalert.org> wrote
> aramssb_svil wrote:
> > In which way can i build this key without using a sequence???
> > I heard a rumour about using a date, but i can't find the way to
> > manipulate the date format of Oracle to obtain not seconds but
fractions
> > of this.
> Whatever you do... do NOT use a DATE type column as a primary key
> (or any other key for that matter). I have seen this done with
> the assumption, "We will never create two orders within one
> second of each other...." . . .
> Even if you can get the date to hold HUNDREDTHS of a second,
> one of these days you WILL get burned.
> . . . create a sequence . . .
I'll second that - I tried building a logging application last week to track changes made to certain tables during a migration process. To save transaction / logging time, I didn't create a numeric key - just tried to use a timestamp column with a default of SYSDATE. And I found that the date, even when TO_CHAR-ed out as far as possible, was NOT UNIQUE ENOUGH for me to apply the transactions to the new system in the exact proper sequence that they occurred. So I created a sequence (as Tim recommends above) and everything worked fine.
Chris
![]() |
![]() |