Oracle SEQUENCE

1.创建SEQUENCE(自增长列 与表无关)

 

CREATE SEQUENCE "CEIADM_TASKS_SEQ" MINVALUE 1 MAXVALUE 99999999 INCREMENT BY 1 START WITH 1 NOCACHE

2.创建触发器,关联表

 

 

CREATE OR REPLACE TRIGGER  "INSERT_CEIADM_TASKS"
BEFORE
insert on "CEIADM_TASKS"
for each row
begin
select "CEIADM_TASKS_SEQ".nextval into :NEW.TASK_ID from dual;
end;

 

你可能感兴趣的:(sequence)