Oracle数据库设置自增id
1.数据库配置:
‘DB_PREFIX’=>’tb_’,//表名前缀
‘DB_SEQUENCE_PREFIX’ => ‘seq_’,//序列名前缀
‘DB_TRIGGER_PREFIX’ => ‘tig_’,//触发器名前缀
2.先创建user数据表
表字段:id, username, password
3.然后创建[序列+触发器]
—-创建序列
create sequence seq_user
increment by 1
start with 1
nomaxvalue
nominvalue
nocache;
—-创建触发器
create or replace trigger “tig_user”
before insert on tb_user
for each row when(new.id is null)
begin
select seq_user.nextval into :new.id from dual;
end;