oracle 自动增长列 例子

--创建序列
create sequence innerid
minvalue 1
maxvalue 999999999
start with 1
increment by 1
cache 20
order;

--创建表
create table users(
userid int primary key,
username   varchar2(20),
userpwd    varchar2(20)
);
select * from users;

insert into users values(innerid.nextval,'zhangsan','123');
insert into users values(innerid.nextval,'lisi','123');
insert into users values(innerid.nextval,'wangwu','123');

--创建触发器
create or replace trigger users_id
before insert on users for each row
begin
     select innerid.nextval into :new.userid from dual;
end users_id;

insert into users(username,userpwd) values('zhaoliu','123');

select * from users;

commit;

 

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