Click here to Skip to main content
15,895,809 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have created a table and now i have to set the auto increment property to the created table field 'id' without using 'create sequence'.
NOTE:the field 'id' is not a primary key
Thanks in advance.
Posted
Updated 30-Dec-11 2:16am
v2

AFAIK in Oracle there's no such concept as auto increment column. Sequences are used to generate surrogate keys. The value given by a sequence can be used anywhere, not only in primary keys.

You can mimic the behaviour of auto incerement columns by creating an insert trigger on your table and setting the field value using a sequence in the trigger. This way the client application 'thinks' the column is autogenerated.
 
Share this answer
 
In Oracle, you can create an autonumber field by using sequences. A sequence is an object in Oracle that is used to generate a number sequence. This can be useful when you need to create a unique number to act as a primary key.
Reference Link :-
Oracle/PLSQL: Sequences (Autonumber)[^]
Creating BETTER auto-increment columns in Oracle[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900