Oracle实现表自增(序列+索引)

创建索引
create sequence xxx_Id_seq
minvalue 1
maxvalue 9999999999999
start with 1
increment by 1
nocache;

添加触发器
create or replace trigger xxx_table_id_trig
before insert on "xxx_table"
for each row
BEGIN SELECT xxx_Id_seq.NEXTVAL INTO :NEW."id" FROM DUAL;
END;

你可能感兴趣的:(Oracle实现表自增(序列+索引))