create sequence SEQ_ID minvalue 1 maxvalue 99999999 start with 1 increment by 1 nocache order; 建解发器代码为: create or replace trigger tri_test_id before insert on test --S_Depart 是表名 for each row declare nextid number; begin IF :new.id IS NULL or :new.id=0 THEN --DepartId是列名 select SEQ_ID.nextval --SEQ_ID正是刚才创建的 into nextid from sys.dual; :new.id:=nextid; end if; end tri_test_id;