1.首先需要创建一个序列
create SEQUENCE tableseq start with 1 increment by 1 minvalue 1 maxvalue 9999999999 nocache nocycle noorder
create sequence tableseq
increment by 1
start with 1
maxvalue 999999999;
得到序列的SQL语句
select tableseq .nextval from sys.dual;
删除序列的SQL
DROP SEQUENCE tableseq
2.建立一个触发器
create or replace trigger tabletrigger before insert on table1 for each row begin select tableseq .nextval into :new.SEQUENCE from dual; end;
触发器名字
表名
序列名字
表中需要自增的列(类型一般为Number)