Re: Unique ID's question
Date: 1996/04/22
Message-ID: <4lftbl$d9k_at_prufire4.prusec.com>#1/1
Jesse <keller_at_minerva.cis.yale.edu> wrote:
>Sorry for asking a typical novice question, but...
>
>Does Oracle7 provide a good way to generate sequential unique ID's, so
>that each new record gets a unique number for its ID field? If the
>solution requires pl/sql, can it be invoke via oraperl?
>
Use oracle database object "SEQUENCE".
create sequence serial_no;
insert into table t1(col_1,col_2,col_3)
values(serial_no.nextval, sysdate,user);
Above insert statement inserts into table t1 with next generated value of sequence serial_no.
select serial_no.nextval from dual;
(returns next val generated for the sequence)
select serial_no.curval from dual;
(returns current value of sequence)
To reset sequence numbers drop and re-create sequence.
To get more information of sequences query data dictionary view USER_SEQUENCES
--
Sanjay D.S.
Oracle Consultant
Prudential Securities, Inc.
Received on Mon Apr 22 1996 - 00:00:00 CEST