可以创建一个Sequence ,插入的时候 插入NextVal值例如
create sequence ID_SEQ
minvalue 1
maxvalue 9999999999
increment by 1;插入的时候 insert into t1 values(ID_SEQ.NextVal)
create sequence ID_SEQ
minvalue 1
maxvalue 9999999999
increment by 1;插入的时候 insert into t1 values(ID_SEQ.NextVal)
创建序列:
CREATE SEQUENCE seq_name
INCREMENT BY 1
START WITH 1
MINVALUE 1
MAXVALUE 999999999
CYCLE
NOORDER
CACHE 50
/
使用序列:
SELECT LTRIM(TO_CHAR(seq_name.NEXTVAL,'000000000')) INTO v_var FROM DUAL;
方法二
建个表来存储你的序号,然后写个函数生成新的序列号
minvalue 1
maxvalue 9999999999
increment by 1
start with 1create or replace trigger TR_mytrigger
before insert on m_table
for each row
begin
select ID_SEQ.nextval into :new.id from dual;
end