1、建用户数据表
create table t_user(
userid number primary key,
name varchar2(20),
sex varchar2(3)
);
2、创建自动增长序列
create sequence SEQ_ID_T_USER
minvalue 1
maxvalue 99999999
start with 1
increment by 1
cache 20;
3、创建触发器
create or replace trigger tri_id_t_user
before insert on t_user
for each row
begin
select SEQ_ID_T_USER.nextval into :new.userid from dual;
end;
4、提交
insert into t_user(name,sex) values ('wang','女');
commit;
create table t_user(
userid number primary key,
name varchar2(20),
sex varchar2(3)
);
2、创建自动增长序列
create sequence SEQ_ID_T_USER
minvalue 1
maxvalue 99999999
start with 1
increment by 1
cache 20;
3、创建触发器
create or replace trigger tri_id_t_user
before insert on t_user
for each row
begin
select SEQ_ID_T_USER.nextval into :new.userid from dual;
end;
4、提交
insert into t_user(name,sex) values ('wang','女');
commit;