• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2190
  • Last Modified:

Auto Increment an ID in Oracle 10G via GUI

I'm a SQL guy; in MS SQL, I can set a Primary Key with an auto increment with whatever seed values that are needed.  Can I do this in the Oracle GUI or do I need to to do this via SQL Plus?

1 Solution
johnsoneSenior Oracle DBACommented:
Oracle does not have an auto increment field.

You would have to create a sequence to keep track of the values.  Then you can either put the increment of the sequence into the insert statement, or you can use a trigger to generate it.
By GUI do you mean Enterprise manager? If so, yes, but you use sequences.

There is no auto-increment column type, however, you must use the sequence in your insert statemnts for that column. You can implement auto-increment columns using a before insert trigger.
In Oracle you can create sequence and use it in BEFORE INSERT trigger to provide a primary key value

create table test (id number, testdata varchar2(255));

create sequence test_seq
start with 1
increment by 1

create trigger test_trigger
before insert on test
for each row
select test_seq.nextval into :new.id from dual;

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now