Oracle不能像MySQL那样设置主键自增,Oracle用 <序列+触发器>的方式使数据表的一列或多列实现自增
序列sequence+触发器trigger:实现数据表S_Dept中的主键的自增
触发器trigger:S_Dept_T
create or replace trigger "S_Dept_T"
before insert on S_Dept for each row
begin
select S_Dept_S.nextval into :new.Dept_Id from dual;
end;
序列sequence:S_Dept_S
-- Create sequence
create sequence S_Dept_S
minvalue 1
maxvalue 999999999999999999999999999
start with 1430
increment by 1
nocache;
网友评论