Oracle主键自增长

-- 建表:
create table test(
  id number(5) primary key,
  name varchar2(25)
);

-- 建序列:

create sequence s_test
minvalue 1
maxvalue 99999999999999999999999999
start with 123
increment by 1
cache 20;

-- 建立触发器
create trigger t_test before insert on test for each row
begin
select s_test.nextval into :new.id from dual;
end;

你可能感兴趣的:(oracle,cache)