| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.misc -> HELP: Sequences and primary keys beginner question.
Hi,
I realize that this question must have been asked many times. However, I have looked at all the FAQ pages I can find and have looked through many manuals for many hours with no luck, so I turn to you.
I want to use a sequence to create the next number for a primary key field. All the manuals indicate that this is 'easy' or 'convenient', but none of them tell me how.
I know that I cannot make reference to the sequence's NEXTVAL in the DEFAULT column in the CREATE TABLE command (though this amazes me).
I know how to write a trigger that will fire on an INSERT statement and populate the keyed field with the NEXTVAL. I know that I can also include the NEXTVAL in every insert command I ever perform against a table.
I just can't believe that I have to do this for every table that I want to have an autoincrementing primary key! There's got to be a better way, this just seems incredibly laborious.
Any help would be greatly appreciated. Please reply to my email address below (after modification).
Thank you,
________________________________________________
Ben Harmon
![]() |
![]() |