1.创建用户数据表
CREATE TABLE USERTEST
(
id number not null,
uname varchar2(20) not null,
upass varchar2(20) not null
);
2.创建自动增长的序列
create sequence ID_SEQ
minvalue 1
maxvalue 999999999999999999999999999
start with 1
increment by 1
cache 20
order;
3.创建触发器,在执行插入操作的时候触发
create or replace trigger uid_trigger
before insert on USERTEST
for each row
begin
select id_seq.nextval into :new.id from dual;
end;
4.提交,检测一下自增长主键的设定
insert into USERTEST(uname,upass) values('张三','1233');
commit;