Oracle Sequence与Trigger的使用

一:建立sequence

-- Create sequence 

create sequence SEQ_PUSH

minvalue 1

maxvalue 9999999999

start with 1

increment by 1

cache 20;

二:建立Trigger

  在向t_push表中插入一条数据时,ID自动赋值

create or replace trigger tr_id_insert

  before insert on t_push  

  for each row

declare

  -- local variables here

begin

  select seq_user_id.nextval into :new.id from dual;

end tr_id_insert;

 

你可能感兴趣的:(sequence)