yes..you need use sequence in oracle for auto increment.
Main Topics
Browse All TopicsHow do I create am auto increment field in Oracle 9i.
I believe it has something to do with triggers but am unable to create or find example code.
Thank you in advance
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Yes, contrary to SQL Server where you can define an implicit sequence using the "IDENTITY" key word when creating your table, in Oracle, you need to create explicitly a sequence with the code mattdee89 gave you. But in this piece of code there are all the parameters a sequence needs. By default, a sequence starts with 1, increments by 1, doesn't cycle, doesn't compute any cache, and goes up to almost infinity.
To use it, you can either use mattdee89's answer or striaght in your query use the "mySequence.nextval" statement to increment the mySequence's value.
It would give something like this if you had a table named "myTable" with a single column named "myTableID" which shoud be incremented :
insert into myTable(myTableID) values (mySequence.nextval)
Try it ! You really do not have to use a trigger to be able to use a sequence easily.
Bye
Denis
Business Accounts
Answer for Membership
by: mattdee89Posted on 2002-12-01 at 16:00:40ID: 7518059
First create a sequence in the schema... ____ ____
____
____
I use a 'demo' schema -->
__________________________
CREATE SEQUENCE "DEMO"."SEQ_INSERT" INCREMENT BY 1 START WITH
1780229 MAXVALUE 1.0E28 MINVALUE 1 NOCYCLE
CACHE 20 ORDER
__________________________
Next place a trigger on the column on the table that you want to auto-increment. My table is 'emp' and column is 'emp_no' -->
__________________________
CREATE OR REPLACE TRIGGER "DEMO"."TRG_EMP_INSERT" BEFORE
INSERT ON "DEMO"."EMP"
FOR EACH ROW BEGIN
SELECT seq_insert .nextval -- get the new seq number
INTO :NEW.emp_no -- :NEW missed
FROM DUAL;
END;
__________________________
If you have questions or problems, shoot me an email..
-Matt
mattdee89@hotmail.com