Re: Help! Primary Key/Normilization Questions?

From: Mike J Cox <mike_at_kane.demon.co.uk>
Date: 1995/07/08
Message-ID: <72410363wnr_at_kane.demon.co.uk>#1/1


> - Is there a way in Oracle to simulate the Access counter type? I
> tried the Oracle type ROWID but no luck.
>

Yes use an sequence:

create sequence fred;

(there are of course lots of fancy options you can also specify, see the server guide)

When you want the next value use:

select fred.nextval from sys.dual;

Use as you would any sql thing

ie: insert into bert(id, name)

    select fred.nextval, name
    from george;

NEVER ATTEMPT TO STORE ROWID .... it relates to the records 'actual' physical location and can therefore change.

> - Is there a way to combine columns to form the primary key?

Yes, a primary key either by constraints or just a unique index can have more than one column, usual practice though that 3 or more columns a surrogate id with sequence be implemented, makes foreign key usage easier.

Mike

-- 
******************************************************************************
Michael Cox          Input Technolgies Ltd
Email                mike_at_kane.demon.co.uk
Compuserve           100045.1715_at_compuserve.com
******************************************************************************
Received on Sat Jul 08 1995 - 00:00:00 CEST

Original text of this message