Oracle实现自增列
jopen
10年前
Oracle实现自增列,通常采用序列+触发器实现:
首先,创建序列:
create sequence seq_test minvalue 1 maxvalue 99999999999 start with 1 increment by 1 cache 20;
其次,创建触发器:
create or replace trigger tiger_test before insert on tb_test for each row begin select seq_test.nextval into :new.id from dual; end;