Re: A Good Way to Create a Unique Key?

From: Chuck Gautney <gautneyc_at_haven.ios.com>
Date: 1995/06/24
Message-ID: <3sfoeq$i5q_at_ankh.iia.org>#1/1


Hooman Azmoodeh (azmoodeh_at_netcom.com) wrote:
: Hi,
: What is the best way to create a unique key for a table?
: We have a table where unique rows can be identified by concatenating
: four fields. This however makes SQL statements very long. For the sake
: of simplicity, is there a way to generate a unique key and perhaps add it
: to the table as a separate column?
: Thank you in advance for your help.
: Mickey
 

: Senior Programmer/Analyst
: InterActive Audiotext Services
: Canoga Park, California

Sure,

Create a unique key sequence ex:
  create sequence test_uniq_key

         increment by 1
         start with 1
         nocycle
         order;

then add a numeric field to the table for the key ex:

create table test_uniq (uniq_key number,col1 varchar2(20)...);

when inserting into the table use the sequence for the uniq_key column ex:   insert into test_uniq(uniq_key,col1...)

                   values(test_uniq_key.nextval,'test insert 1',...);


Chuck Gautney
Independent Financial Systems Specialist gautneyc_at_haven.ios.com Received on Sat Jun 24 1995 - 00:00:00 CEST

Original text of this message