CREATE SEQUENCE s_userId
INCREMENT BY 1 -- 每次加几个
START WITH 1 -- 从1开始计数
NOMAXVALUE -- 不设置最大值
NOCYCLE -- 一直累加,不循环
NOCACHE -- 不建缓冲区 3.建立触发器:
//drop sequence s_userId; 删除
//select object_name from user_objects where object_type='SEQUENCE';如何查看和修改oracle 自动增长列
//select s_userId.nextval from dual;
create table userInformation
(
userId int primary key not null,
userName varchar2(12),
userAge int,
userAdderess varchar2(120),
userTelephone int
) tablespace testTableSpace;
insert into userInformation values(s_userId.nextval,'李红军',21,'武汉市江岸',13023131231);
insert into userInformation values(s_userId.nextval,'张三',21,'武汉市江岸',13023131231);
insert into userInformation values(s_userId.nextval,'李四',21,'武汉市汉阳',13023131231);
insert into userInformation values(s_userId.nextval,'王五',21,'武汉市武昌',13023131231);
insert into userInformation values(s_userId.nextval,'赵六',21,'武汉市汉口',13023131231);
insert into userInformation values(s_userId.nextval,'许七',21,'上海市徐汇',13023131231);
insert into userInformation values(s_userId.nextval,'洪八',21,'上海市闵行',13023131231);
select * from userInformation;
//触发器绑定自增长列
create or replace trigger test
before insert on goodsdoc
for each row
when (new.billno = 0)
declare
-- local variables here
begin
select s_userid.nextval into :new.billno from dual;
end test;
//sqlserver 自增长列
alter table skzy..goodsdoc add seqno int identity(1,1)