Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Autonumber
A copy of this was sent to Venkatesh Kumar <venkatesh.kumar_at_sabre.com>
(if that email address didn't require changing)
On Thu, 02 Dec 1999 08:27:14 -0600, you wrote:
>I am fairly new to Oracle.All my experience was
>previously in MS-Access and SQL Server.Can
>anyone tell me on How I declare a column as a
>autonumber(in other words a number that increments by
>itself,every time
>a new record is added).I want to make this column the
>primary key of the table.
>
>Any help is greatly appreciated
>
>
create sequence my_seq;
create or replace trigger my_trigger before insert on my_table
for each row as
begin
select my_seq.nextval into :new.primary_key_column 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 Thu Dec 02 1999 - 08:52:05 CST
![]() |
![]() |