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-Numbering field (how??)

Re: Auto-Numbering field (how??)

From: Karsten Farrell <kfarrell_at_medimpact.com>
Date: Tue, 29 Oct 2002 00:22:32 GMT
Message-ID: <cxkv9.1809$034.115475503@newssvr13.news.prodigy.com>


the_clansman wrote:
> Hi,
>
> As per the title, how to make a auto-numbering field with Oracle? I would
> like to have a table with the following structure:
>
> ID (autonumber: lenght=4)
> LAST NAME VARCHAR2(25)
> FIRST NAME VARCHAR2(25)
> PASSWORD VARCHAR2(10)
>
> Thank you!
>

1. Create a sequence:

    CREATE SEQUENCE seq_1 ...;

2. On your INSERT statement, reference the sequence you just created:

    INSERT INTO table (column_1, ..., column_n)     VALUES (seq_1.nextval, ..., value_of_column_n);

There are a couple of options on the CREATE SEQUENCE (like min/max values, increment, etc). Look it up in the SQL reference manual (see http://tahiti.oracle.com for the doc set if you don't have it on your local PC).

/Karsten Received on Mon Oct 28 2002 - 18:22:32 CST

Original text of this message

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