Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: how to set the column be auto increment no.??
Originally posted by Myhome
> I want to create a table with a field called "seqno" that is a auto
> increment number. What is the stynax of setting auto increment??
>
> Now, I create my table temporily by this statement:
> create table AAA (seqno number(10) not null)
>
> thx
There is no auto-incrementing column in Oracle like there is in SQL
Server. Instead, create a sequence like this:
CREATE SEQUENCE myseq;
Then when inserting values you can do this:
INSERT INTO aaa (seqno) VALUES (myseq.NEXTVAL)
Alternatively you could create a BEFORE INSERT trigger on the table to get myseq.NEXTVAL so that the insert statement doesn't have to include seqno.
-- Posted via http://dbforums.comReceived on Fri Jul 04 2003 - 06:16:41 CDT
![]() |
![]() |