oracle实现自动增加
//创建sequence user_seq(sequence名字)
create sequence user_seq
start with 1
increment by 1
nomaxvalue
nocycle;
//此时可以这样插入,自动增加
insert into users (id,name,ms) values(user_seq.nextval,'2','dd');
//创建触发器,绑定只有users表才能使用此sequence cfq_user(触发器名字) users(表名)
create or replace trigger cfq_user
before insert on users
for each row
begin
select user_seq.nextval into :new.id from dual;
end;
//创建触发器后,不用写id,这样插数据库中的表也会自动增加
insert into users (name,ms) values('s','dd');