How to create id with AUTO_INCREMENT on Oracle?

后端 未结 16 1591
死守一世寂寞
死守一世寂寞 2020-11-21 04:52

It appears that there is no concept of AUTO_INCREMENT in Oracle, up until and including version 11g.

How can I create a column that behaves like auto increment in Or

16条回答
  •  北海茫月
    2020-11-21 05:55

      create trigger t1_trigger
      before insert on AUDITLOGS
      for each row
       begin
         select t1_seq.nextval into :new.id from dual;
       end;
    

    only I have to just change the table name (AUDITLOGS) with your table name and new.id with new.column_name

提交回复
热议问题