1.新建表
create table test (
id int, primary key,
username varchar2(20)
);
2.新建sequence
create sequence id_seq
minValue=1
maxValue=9999999
start with 1
increment by 1
nocycle
3.新建触发器
create trigger id_trigger
before insert on scott.test
for each row
begin
select id_seq.nextVal into:New.id from dual;
end;
4.测试
insert into test(username) values('xx');
commit;