Oracle主键自增长

 

--创建序列      
create sequence menu_seq start with 1 increment by 1;
--创建触发器      
create or replace trigger menu_trigger
  before insert on sys_menu
  for each row
  begin
    select menu_seq.nextval into :new.id from dual;
  end ;
--添加数据      
insert into sys_menu(name)  values ('cc');
insert into sys_menu(name)  values ('dd');
commit;

你可能感兴趣的:(Oracle数据库)