日期:2014-05-16  浏览次数:20384 次

oracle int自增长
  1. 先建表(此处略去)
  2. 创建Sequence
 
  create sequence template_seq
  start with 1
  increment by 1
  nocycle
  cache 99999
  

  3.创建触发器
 
create trigger template_trig before
insert on template for each row--template是表名
declare
nextid number;
begin
if:new.templateid is null or :new.templateid=0 then--templateid是template表的列
select template_seq.nextval into nextid from sys.dual;
:new.templateid:=nextid;
end if;
end;