Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> Re: Assign unique primary key for new rows

Re: Assign unique primary key for new rows

From: <sanrenkur_at_my-deja.com>
Date: 2000/05/30
Message-ID: <8h1k5q$4r7$1@nnrp1.deja.com>#1/1

In article <3934249D.F8E4BA1E_at_mediashell.net>,   leenick_at_bigfoot.com wrote:
> Hi,
>
> Another newbie question ...
>
> Is there any way I can get Oracle to automatically assign a unique
> value to one of the columns for every new rows that I add? That column
> can, in turn, be the primary key of the table.
>
> Any help is greatly appreciated,
> EN
>

Hi
Yes, with a sequence
CREATE SEQUENCE my_sequence
INCREMENT BY some_number(1 for example)
START WITH some_number
NOCYCLE; To insert this value
INSERT INTO my_table (ID, other cols, etc) VALUES (my_sequence.NEXTVAL, other cols, etc)

Hth
Sanrenkur

Sent via Deja.com http://www.deja.com/
Before you buy. Received on Tue May 30 2000 - 00:00:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US