2018-06-26
一、oracle建立sequence和触发器
1、建表
create table a_user
(
id INTEGER not null primary key,
username VARCHAR2(64) not null,
mobile VARCHAR2(16) not null
);
2、建立sequence
create sequence user_seq
increment by 1
start with 1
nominvalue
nomaxvalue
nocache;
3、建立触发器
create or replace trigger tr_user
before insert or update on a_user
for each row
begin
select user_seq.nextval into :new.id from dual;
end;