oracle创建自增

1.

create sequence tab_seq

minvalue 1

maxvalue 99999999

start with 1

increment by 1

nocache

order;

2.  insert into table(id,,) values(tab_id.nextval,,)

/或创建触发器----创建触发器
create or replace trigger tr_user
before insert on tablename
for each row
begin
select tab_seq.nextval into :new.id from dual;
end;


3. 最好不用触发器,则比较容易获取自增id的最新插入值select 序列名.currval from dual

你可能感兴趣的:(Oracle自增)