We help IT Professionals succeed at work.

Create Table : Field with auto-number

msl22
msl22 asked
on
Hi,

I'm working with Oracle 8i, and I'd like to create a table. The first column of this table a number type and is an ID. I don't want to give myself  the number of this field, instead, I want the table auto create the number each time I create a new record in this table. (1, 2, 3, ...)

Which option should I use to create this type of column ?

Thank you.

Mary.
Comment
Watch Question

BRONZE EXPERT
Top Expert 2004
Commented:
create a sequence and a before insert trigger to supply your id-field with the nextval-value of the sequence

Author

Commented:
Thank you Kretzschmar !

Author

Commented:
Hi,

I have problem....
When I tried to compile my trigger, it says that the Sequence referenced 'Seq_Agencies.nextval' is not allowed in this context....

Can you help me on this ?

Thank
BRONZE EXPERT
Top Expert 2004

Commented:
try

select Seq_Agencies.nextval into :new.idfieldname from dual

Author

Commented:
Thanks !!

Explore More ContentExplore courses, solutions, and other research materials related to this topic.