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: create an automatic index for primary key column

Re: create an automatic index for primary key column

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: Sun, 12 Dec 1999 19:13:58 -0500
Message-ID: <hge85sk9mhc86cmf4nc9r0f0mkt9uhjol3@4ax.com>


A copy of this was sent to <accesavi_at_netvision.net.il> (if that email address didn't require changing) On Sun, 12 Dec 1999 22:30:06 GMT, you wrote:

>when i create a table, i need to create an automatic index value(integer)
>1,2,3...
>increasing value for the primary key column.
>
>
>thanks a lot.

create sequence my_seq;

create or replace trigger my_trigger
before insert on T for each row
begin
  select my_seq.nextval into :new.id from dual; end;

--
See http://osi.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 Sun Dec 12 1999 - 18:13:58 CST

Original text of this message

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