Re: Auto Increment Column? [message #372421] |
Mon, 12 February 2001 02:42 |
timmy
Messages: 10 Registered: February 2001
|
Junior Member |
|
|
yes there is....in oracle you create a sequence....
CREATE SEQUENCE name_seq
start with 1
increment by 1
nomaxvalue
nocycle
cache 10;
cache option preallocates a set of seqencial nums and keeps them in memory..if you don't have it, don't script it...next..when you insert values into your table it would like like this
INSERT INTO table_name (field_name that your sequencing i.e. item, name, address, city, etc)
VALUES (NAME_SEQ.NEXTVAL, Hosea, box 69, wherever, etc;
let me know if you need more help....timmy
|
|
|
Re: Auto Increment Column? [message #372425 is a reply to message #372421] |
Mon, 12 February 2001 09:40 |
timmy
Messages: 10 Registered: February 2001
|
Junior Member |
|
|
forgot a parenthesis on....
INSERT INTO table_name (field_name that your sequencing i.e. item, name, address, city, etc)
VALUES (NAME_SEQ.NEXTVAL, Hosea, box 69, wherever, etc);
corrected version shown...sorry.....
|
|
|
Re: Auto Increment Column? [message #372457 is a reply to message #372421] |
Wed, 14 February 2001 04:01 |
John R
Messages: 156 Registered: March 2000
|
Senior Member |
|
|
A better approach to the insert statement would be to create a Before Row Insert trigger on the table to automatically populate the primary key field with the next value from the sequence.
|
|
|