Solved

Auto Increment an ID in Oracle 10G via GUI

Posted on 2009-07-01
3
1,703 Views
Last Modified: 2012-05-07
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?

Thx
0
Comment
Question by:Glen_D
3 Comments
 
LVL 34

Expert Comment

by:johnsone
ID: 24754188
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.
0
 
LVL 40

Expert Comment

by:mrjoltcola
ID: 24754225
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.
0
 
LVL 47

Accepted Solution

by:
schwertner earned 500 total points
ID: 24754486
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
nomaxvalue;

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

0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now