Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2003
    Location
    In your thoughts
    Posts
    195

    Unanswered: Auto Increment By 1

    I need to set up a column in a table to auto increment by one when a row is added to that table. Can someone help me out? Thanks, Jeremy
    Nothing better than a good ride.

  2. #2
    Join Date
    Nov 2002
    Location
    Desk, slightly south of keyboard
    Posts
    697
    There isn't such a thing as an autoinc field in Oracle, instead....

    create sequence test_seq start with 1 increment by 1 cache 20 nocycle;

    create table test_tbl (id number(12));

    create or replace trigger test_id_trg
    before insert on test_tbl
    for each row
    begin
    select test_seq.nextval into :NEW.ID from dual;
    end;

    hth
    Bill

  3. #3
    Join Date
    Feb 2003
    Location
    In your thoughts
    Posts
    195
    Just found that. Thanks bud, Jeremy
    Nothing better than a good ride.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •