用代码来实现oracle自动增加1功能

用代码来实现oracle自动增加1功能

创建序列:-- Create sequence

create sequence IP_Test_SEQUENCES

minvalue 1

maxvalue 99999999999999999999999999

start with 1

increment by 1

cache 20

order;

创建触发器:

create or replace trigger IP_Test_Trigger

  before insert on ip_test

  for each row

declare

  -- local variables here

  next_id number;

begin

 select IP_Test_Sequences.nextval into next_id from dual;

 :new.id:=next_id;

 --select IP_Test_Sequences.nextval into :new.id from dual;

end IP_Test_Trigger;

你可能感兴趣的:(用代码来实现oracle自动增加1功能)