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

Home -> Community -> Usenet -> c.d.o.misc -> Re: auto increment of primary key in ORACLE

Re: auto increment of primary key in ORACLE

From: Mikel <not_at_me.com>
Date: Mon, 9 Aug 1999 22:10:19 -0400
Message-ID: <RYLr3.57827$jl.36656958@newscontent-01.sprint.ca>


1 create a sequence

CREATE SEQUENCE pk_seq INCREMENT BY 1;

2 code the insert statement to insert the nextval of the sequence

INSERT INTO emp (empno, ename, job, sal, comm, deptno)

   VALUES (pk_seq.netval, 'JINKS', 'CLERK', 1.2E3, NULL, 40);

You do not need a trigger as other posts say if you are writing the insert code.

Mike

wolfgang karrer <wolfgang.karrer_at_ce.uni-linz.ac.at> wrote in message news:37AE7559.7592CB7C_at_ce.uni-linz.ac.at...
> Hi,
>
> is it possible to auto increment the primary key of a table, like
>
> table emp
> empnr INTEGER primary key
>
> thanx for helping me!
>
Received on Mon Aug 09 1999 - 21:10:19 CDT

Original text of this message

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