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: Autonumber

Re: Autonumber

From: Alan Shein <alanshein_at_erols.com>
Date: Thu, 2 Dec 1999 09:58:27 -0500
Message-ID: <8261e3$cmg$1@autumn.news.rcn.net>


You first need to create a Sequence:

CREATE SEQUENCE my_sequence INCREMENT BY 1 START WITH 1

You then use the sequence to populate the field. In an INSERT, it could look like this:

INSERT INTO my_table (my_pk_column, my_column1, my_column2) VALUES (my_sequence.nextval, my_value1, my_value2);

Of course, you would declare a Primary Key constraint on my_pk_column when you create the table.

Venkatesh Kumar <venkatesh.kumar_at_sabre.com> wrote in message news:384681C2.1C8817FC_at_sabre.com...
> 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
>
>
>
Received on Thu Dec 02 1999 - 08:58:27 CST

Original text of this message

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