oracle 主键自增

第一步

create table test
(id int primary key,
name varchar2(10));

第二步 创建主键seq

create sequence test_seq increment by 1 start with 1 
minvalue 1 maxvalue 9999999999999 nocache 
order;

第三步 绑定触发

create or replace trigger test_trigger
before insert on test
for each 
row
begin
 select  test_seq.Nextval into:new.id from dual;
end;  

你可能感兴趣的:(oracle 主键自增)