Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Building a primary key
aramssb_svil wrote:
>
> Hi there!!!
>
> I have a question that seem to be simple...
>
> I have to identify each row in my table with a unique key.
>
> 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...." Famous last words. I don't know what your aversion to sequences is, but this is exactly what they are for - create a sequence and populate a good old fashioned numeric column with it. Of course you'll also want to create a primary key constraint on that column. Even if you can get the date to hold HUNDREDTHS of a second, one of these days you WILL get burned.