| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Auto-Numbering field (how??)
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
![]() |
![]() |