oracle 序列和触发器实例
--建立自增序列 create sequence seqid NOMAXvalue start with 1 increment by 1 nocache order; --建立触发器 create or replace trigger tri_test_id before insert on mytable --mytable为要插入自增序列的表 for each row declare nextid number; begin IF :new.Id IS NULL or :new.Id=0 THEN --id是要插入自增序列的列名 select seqid.nextval into nextid from sys.dual; :new.Id:=nextid; end if; end tri_test_id;