先写一个序列 create sequence SEQ_TIME_STAMP minvalue 10000 maxvalue 99999 start with 10001 increment by 1 nocache cycle;
再写个触发器 create or replace trigger 触发器名 before insert on 表名 for each row begin Select to_char(sysdate,'yyyymmdd')||seq_time_stamp.nextval Into :new.报表信息编号 from dual; end;
当你insert时, 报表信息编号 系统就会自动生成流水号了
上帝的女孩
2024-10-11 09:59:39
用日期+序列号不行的么?
select to_char(sysdate,'yyyyMMDD')||to_char(xh_seq.nextval,'0000') from dual;
夏櫻之雨
2024-10-11 08:36:32
insert into tab1(id) values(to_char(sysdate,'yyyymmdd')||lpad(seq.nextval,4,0))