Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Index as primary key?
In article <6n7sgc$mtf$1_at_nnrp1.dejanews.com>,
rbook_at_my-dejanews.com wrote:
>
> Hi!
>
> For building the primary key in an dimension table i decided to
> use an own generated index.
> Can i use an index as primary key in ORACLE7?
> How should i do?
> It is better to generate an artifical primary key?
>
> Thank you!
> Ralf
Please be more explicit about what you actually want.
Here are some guesses:
1.) Technically, a UNIQUE INDEX on Columns with the
NOT NULL Property is equivalent to a primary key.
This means "go ahead, use your index" if you
referred to Oracle Indices created with
CREATE UNIQUE INDEX.
2.) You can use an autogenerated value as artificial
primary key *value* by defining a BEFORE INSERT-Trigger
which pulls from a sequence number into your
primary key column.
3.) Sometimes artificial keys are indeed the better choice
(ever tried to update a primary key column that has
referencing foreign key rows in another table?)
In this case, use technique 2.) for an artificial PK
*and* use tehchnique 1.) to ensure uniqueness of the
alternate key.
Hope this helped, Robert.
-----== Posted via Deja News, The Leader in Internet Discussion ==----- http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum Received on Tue Jun 30 1998 - 05:13:15 CDT