Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: auto increment of primary key in ORACLE
A copy of this was sent to wolfgang karrer <wolfgang.karrer_at_ce.uni-linz.ac.at>
(if that email address didn't require changing)
On Mon, 09 Aug 1999 08:29:46 +0200, you wrote:
>Hi,
>
>is it possible to auto increment the primary key of a table, like
>
>table emp
>empnr INTEGER primary key
>
>thanx for helping me!
sequences are for this.
create sequence emp_seq;
create or replace trigger emp_trigger
before insert on emp for each row
begin
select emp_seq.nextval into :new.empnr from dual; end;
will do it.
--
See http://govt.us.oracle.com/~tkyte/ for my columns 'Digging-in to Oracle8i'...
Current article is "Part I of V, Autonomous Transactions" updated June 21'st
Thomas Kyte tkyte_at_us.oracle.com Oracle Service Industries Reston, VA USA
Opinions are mine and do not necessarily reflect those of Oracle Corporation Received on Mon Aug 09 1999 - 07:27:01 CDT
![]() |
![]() |